服务器关闭时当前正在运行的石英作业会发生什么
我们有一个基于 SQL 的石英调度程序。有一个作业处理 100k 条记录并运行 2 小时。如果在作业仍在运行的情况下启动服务器关闭,则在服务器重新启动后作业会再次启动吗?
We have a SQL based quartz scheduler. There is a job that processes 100k records and runs for 2 hours. If a server shutdown is initiated with the job still running, will the job start again after the server is restarted?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查
RequestsRecovery - 作业是否“请求恢复”,并且在该时间内正在执行调度程序的“硬关闭”(即,它正在崩溃中运行的进程,或者机器被关闭),然后当调度程序再次启动时,它会重新执行。在这种情况下,JobExecutionContext.isRecovering()方法将返回true。
只要您有 JDBC 数据存储,这就可以工作。
Check
RequestsRecovery - if a job "requests recovery", and it is executing during the time of a 'hard shutdown' of the scheduler (i.e. the process it is running within crashes, or the machine is shut off), then it is re-executed when the scheduler is started again. In this case, the JobExecutionContext.isRecovering() method will return true.
As long as you have JDBCData store, this will work.
当您使用 JDBC 配置属性创建调度程序工厂时,您需要将调度程序详细信息存储在 JDBC JobStore 中。
之后,您可以从元数据中提取它,并根据故障时间,您可以检索调度程序详细信息并根据您的要求恢复它。
请参考:- 使用 JDBC JobStore 的 Quartz Scheduler
另一种替代方法是您可以创建您自己的调度程序侦听器并将其分配给调度程序。参考:- https://examples.javacodegeeks.com/enterprise- java/quartz/quartz-scheduler-tutorial/
You need to store your scheduler details JDBC JobStore when you are creating Scheduler factory with JDBC configuration properties.
After that, you can extract it from the metadata and according to the failure time you can retrieve your scheduler details and resume it according to your requirement.
Please refer:- Quartz Scheduler using JDBC JobStore
One more alternative way is that you can create your own Scheduler Listener and assign it to the scheduler. Reference :- https://examples.javacodegeeks.com/enterprise-java/quartz/quartz-scheduler-tutorial/