问题
We're using Quartz 1.8.6 in our app. We are using CronTriggers for hourly and nightly jobs. We would like to set things up such that if there is a misfire, we want to skip the job until the next cron time rolls around.
For simple jobs, it appears you can do a
nightlyTrigger.setMisfireInstruction(SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT);
However, it appears that this does not work with CronTrigger. What is the Misfire instruction to use in this case?
回答1:
You want to use CronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING
.
SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT
is telling Quartz that, upon one or more misfires, it must:
- reschedule the trigger to fire upon the next scheduled date (not firing, i.e. ignoring, missed executions).
- Also, set the "repetitions left" counter as if all missed executions had run correctly (not accounting for missed runs either).
So basically this misfire instruction tells Quartz to do nothing at all, smile and keep going like nothing ever happened. The KEEP CALM of misfire instructions.
The equivalent instruction for Cron triggers is much more aptly named: CronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING
.
来源:https://stackoverflow.com/questions/44597977/in-quartz-1-8-6-is-there-an-option-like-misfire-instruction-reschedule-next-wit