如何让Quartz Scheduler更早识别错过的作业?
Job应该在 05-12-2014 08:00:00.000 被解雇,但仅在 2014-12-07 23:34:15,800 时确定
2014-12-07 23:34:15,800 INFO [QuartzScheduler_sharedQuartzScheduler-NON_CLUSTERED_MisfireHandler] [,,] [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] Trigger [expiryBreachTrigger.11854] misfired job [Breach.11854]. Should have fired at: 05-12-2014 08:00:00.000
2014-12-07 23:34:15,825 INFO [sharedQuartzScheduler_Worker-40] [,,] [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] Trigger [expiryBreachTrigger.11854] fired job [Breach.11854] scheduled at: 07-12-2014 23:34:15.801, next scheduled at: null
2014-12-07 23:34:15,844 ERROR [sharedQuartzScheduler_Worker-40] [,,] [nz.co.chorus.com.om.service.service.impl.JeopardyManagementServiceImpl] An error occurred while scheduling expiration job for event id 11854: org.quartz.ObjectAlreadyExistsException: Unable to store Job : 'Breach.11854', because one already exists with this identification.
2014-12-07 23:34:15,846 INFO [sharedQuartzScheduler_Worker-40] [,,] [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] Trigger [expiryBreachTrigger.11854] completed firing job [Breach.11854] with resulting trigger instruction code: RE-EXECUTE JOB. Next scheduled at: null
2014-12-07 23:34:15,846 INFO [sharedQuartzScheduler_Worker-40] [,,] [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] Trigger [expiryBreachTrigger.11854] fired job [Breach.11854] scheduled at: 07-12-2014 23:34:15.801, next scheduled at: null
2014-12-07 23:34:15,846 INFO [sharedQuartzScheduler_Worker-40] [,,] [org.quartz.plugins.history.LoggingJobHistoryPlugin] Job [Breach.11854] to be fired by trigger [expiryBreachTrigger.11854], re-fire: 1
2014-12-07 23:34:15,846 DEBUG [sharedQuartzScheduler_Worker-40] [,,] [org.quartz.core.JobRunShell] Calling execute on job Breach.11854
2014-12-07 23:34:15,855 INFO [eventLoggerContainer-1] [,,] [nz.co.chorus.com.event.listener.EventLoggerListener] Event Logger: null
2014-12-07 23:34:15,859 INFO [sharedQuartzScheduler_Worker-40] [,,] [org.quartz.plugins.history.LoggingJobHistoryPlugin] Job [Breach.11854] execution complete and reports: null
2014-12-07 23:34:15,859 INFO [sharedQuartzScheduler_Worker-40] [,,] [org.quartz.plugins.history.LoggingTriggerHistoryPlugin] Trigger [expiryBreachTrigger.11854] completed firing job [Breach.11854] with resulting trigger instruction code: DELETE TRIGGER. Next scheduled at: null
一旦将作业识别为失败的作业,它就会被正确重新安排,但正如您所看到的那样,有一个异常 ObjectAlreadyExistsException ,但这会导致触发指令 RE-EXECUTE JOB 然后作业正确运行。
问题是两天两次确定这个错过的工作太长
final Trigger trigger = TriggerBuilder
.newTrigger()
.withIdentity(Objects.toString(jeopardyEventId),
"expiry" + jobGroup + "Trigger")
.startAt(expirationTime).build();
也许我需要使用失火指令构建触发器
.withMisfireHandlingInstructionIgnoreMisfires()
但我的理解只是意味着当它发现它总会运行工作而不是参考智能政策时。
quartz.properties文件
org.quartz.plugin.triggerHistory.class=org.quartz.plugins.history.LoggingTriggerHistoryPlugin
org.quartz.plugin.triggerHistory.triggerFiredMessage=Trigger [{1}.{0}] fired job [{6}.{5}] scheduled at: {2, date, dd-MM-yyyy HH:mm:ss.SSS}, next scheduled at: {3, date, dd-MM-yyyy HH:mm:ss.SSS}
org.quartz.plugin.triggerHistory.triggerCompleteMessage=Trigger [{1}.{0}] completed firing job [{6}.{5}] with resulting trigger instruction code: {9}. Next scheduled at: {3, date, dd-MM-yyyy HH:mm:ss.SSS}
org.quartz.plugin.triggerHistory.triggerMisfiredMessage=Trigger [{1}.{0}] misfired job [{6}.{5}]. Should have fired at: {3, date, dd-MM-yyyy HH:mm:ss.SSS}
org.quartz.plugin.jobHistory.class=org.quartz.plugins.history.LoggingJobHistoryPlugin
org.quartz.plugin.jobHistory.jobToBeFiredMessage=Job [{1}.{0}] to be fired by trigger [{4}.{3}], re-fire: {7}
org.quartz.plugin.jobHistory.jobSuccessMessage=Job [{1}.{0}] execution complete and reports: {8}
org.quartz.plugin.jobHistory.jobFailedMessage=Job [{1}.{0}] execution failed with exception: {8}
org.quartz.plugin.jobHistory.jobWasVetoedMessage=Job [{1}.{0}] was vetoed. It was to be fired by trigger [{4}.{3}] at: {2, date, dd-MM-yyyy HH:mm:ss.SSS}
org.quartz.jobStore.misfireThreshold=600000
org.quartz.threadPool.threadCount=50
org.quartz.scheduler.skipUpdateCheck=true
答案 0 :(得分:0)
如何让Quartz Scheduler更早识别错过的作业?
根据docs,这由org.quartz.jobStore.misfireThreshold
属性控制。尝试将其设置为较低的值,看看它是否有帮助......