我正在寻找可以处理 Callable
或 Runnable
的通用异步 Java 作业执行框架。它类似于 java.util.concurrent.ExecutorService
,(并且可能包装 ExecutorService
),但它还具有以下特性:
能够将作业持久保存到数据库,以防应用程序在为作业提供服务时出现故障,并且能够重新启动未完成的作业。 (我知道我的工作可能必须实现
Serializable
,这没问题。)使用 UUID 使客户端能够获取作业 token 并查询作业状态。 (在幕后,这些信息也会保存到数据库中。)
我已经开始通过围绕 ExecutorService
构建自己来解决这个问题,但我更喜欢开箱即用的开源解决方案(如果存在的话)。
可以在 Spring Framework 中工作的东西是理想的。
最佳答案
你可能想看看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.
关于java - 搜索通用异步 Java 作业执行框架/库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/612656/