集群模式下的 Spring 和 Quartz 集成不会覆盖现有作业
我正在使用 Spring 3 和 Quartz 1.8.5 以集群模式安排作业。我已经在 Spring 的调度程序配置中放置了 overwriteExistingJobs=true 。
除了使用 Quartz 作业配置的作业之外,我还需要以编程方式创建动态作业。一切正常,直到我重新启动服务器。此时overwriteExistingJobs=true就有问题了。
假设我创建了一个动态作业,每两分钟执行一次。而且,我停止服务器并在十分钟后启动它,该作业在服务器启动后立即执行五次。但是,如果有一项作业是 spring 配置的一部分,例如 spring 文档中给出的作业,那么当服务器重新启动时,它会被覆盖。
我的观察是,对于在 spring 配置文件中配置并添加到 org.springframework.scheduling.quartz.SchedulerFactoryBean 的作业, QRTZ_TRIGGERS 表中的 PREV_FIRE_TIME 更新为“-1”,但对于动态创建的作业,它不会被覆盖。
I am using Spring 3 and Quartz 1.8.5 to schedule jobs in a clustered mode. I have placed, overwriteExistingJobs=true in the Spring's scheduler configuration.
There is a requirement for me to create dynamic jobs programmatically apart from the jobs which are part of the configuration using Quartz jobs. Everything works fine till i re-start the server. At this point , there is a problem with overwriteExistingJobs=true.
Say, if i have a dynamic job created to execute every two minutes. And, i stop the server and start it after ten minutes, the job executes five times as soon as the server starts. But, if there is a job which is part of the spring configuration , like the one given in spring documentation , it is over-written when the server re-starts.
My observation has been that for jobs which are configured in the spring configuration file and added to the org.springframework.scheduling.quartz.SchedulerFactoryBean, the
PREV_FIRE_TIME in QRTZ_TRIGGERS table gets updated to '-1' but for dynamically created jobs it is not over-written.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
修复如下:
a) 我有与动态作业关联的 CronTriggers,所以我所做的是提供失火指令。
b)失火阈值相当高(6000000)。所以,我所做的就是降低失火阈值,而且效果非常好。
The fix is as follows:
a) I have CronTriggers associated with dynamic jobs so what i did was to provide the mis-fire instruction.
b)The mis-fire threshold was pretty high (6000000). So, what i did was to reduce the misfire threshold and it worked like a charm.