I am looking for a generic asynchronous Java job execution framework that could handle Callable
s or Runnable
s. It would be similar to java.util.concurrent.ExecutorService
, (and possibly wrap ExecutorService
), but it would also have the following features:
The ability to persist jobs to a database in case the application goes down while a job is being serviced, and be able to restart the unfinished jobs. (I understand that my job may have to implement Serializable
which is OK.)
Work with UUIDs to enable the client to obtain job tokens and inquire about job status. (Under the hood this information would be persisted to a database, as well.)
I have started working on this myself by building around ExecutorService
, but I would prefer an out of the box, open source solution, if one exists.
Something that could work within the Spring Framework would be ideal.
You may want to look at Quartz.
Quartz is a full-featured, open source job scheduling system that can be integrated with, or used along side virtually any J2EE or J2SE application - from the smallest stand-alone application to the largest e-commerce system. Quartz can be used to create simple or complex schedules for executing tens, hundreds, or even tens-of-thousands of jobs; jobs whose tasks are defined as standard Java components or EJBs. The Quartz Scheduler includes many enterprise-class features, such as JTA transactions and clustering.
You can use Quartz, and create a concrete Job
adapter that delegates to a Runnable
or Callable
. Quartz' Job
interface adds the ability to maintain some state between invocations of a task. If desired, Quartz can store jobs and their state durably in a relational database, and execute them on a scalable cluster of hosts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With