https://github.com/fizzed/executors
Long-lived tasks and workers on the JVM
https://github.com/fizzed/executors
Last synced: 11 months ago
JSON representation
Long-lived tasks and workers on the JVM
- Host: GitHub
- URL: https://github.com/fizzed/executors
- Owner: fizzed
- Created: 2019-06-04T13:02:42.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2025-01-22T20:28:59.000Z (over 1 year ago)
- Last Synced: 2025-04-13T12:51:30.971Z (about 1 year ago)
- Language: Java
- Size: 2 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Executors by Fizzed
[](https://mvnrepository.com/artifact/com.fizzed/bigmap)
[](https://github.com/fizzed/executors/actions/workflows/java8.yaml)
[](https://github.com/fizzed/executors/actions/workflows/java11.yaml)
[](https://github.com/fizzed/executors/actions/workflows/java17.yaml)
[](https://github.com/fizzed/executors/actions/workflows/java21.yaml)
[](https://github.com/fizzed/executors/actions/workflows/java11.yaml)
[](https://github.com/fizzed/executors/actions/workflows/macos-arm64.yaml)
[](https://github.com/fizzed/executors/actions/workflows/windows-x64.yaml)
[Fizzed, Inc.](http://fizzed.com) (Follow on Twitter: [@fizzed_inc](http://twitter.com/fizzed_inc))
Executors by Fizzed helps you build, manage, and operate long-lived workers (threads)
on the JVM.
Java's standard ExecutorService and its various implementations (correctly) hide where
and how your Runnable is executing. They are designed to abstract the run() method.
However, when building long-lived tasks, where some parts of your code are critical
to not be interrupted (e.g. during a graceful shutdown). That's where the lack of
context within your run() of how you're executing becomes a problem. This usually
consists of waiting for work and being able to prevent shutdown until that work is
completed.
This framework is a simple layer built on top of the ExecutorService to give your
Workers the context and building blocks for rock-solid long-lived tasks.
Pattern 1: poll and accept next job (e.g. Blocking Queue)
while (!stopped) {
job = pollAndAcceptNextJob() // <-- critical start
if (job) {
// handle job
} // <-- critical end
sleep(2 seconds) // <-- interrupt ok
}
Pattern 2: poll then accept next job (e.g. JMS w/ manual ack)
while (!stopped) {
job = pollNextJob() // <-- interrupt ok
if (job) {
// accept job (ack it) // <-- critical start
// handle job
} // <-- critical end
sleep(2 seconds) // <-- interrupt ok
}
## Usage
In your `pom.xml` add the following dependency:
```xml
com.fizzed
executors-core
0.0.5
```
## License
Copyright (C) 2025 Fizzed, Inc.
This work is licensed under the Apache License, Version 2.0. See LICENSE for details.