Issue
I have a simple trigger which trigger a simple job (let's assume - send an email).
My trigger:
return newTrigger()
.withIdentity(name, group)
.withSchedule(
simpleSchedule()
.withMisfireHandlingInstructionNextWithExistingCount()
)
.startAt(triggerStartTime)
.usingJobData(JobDataMap(triggerData))
.withDescription(description)
.build()
But, imagine that service will not available at triggerStartTime
fired time (I just shut down database and my service). Some time later, when I run my service again - in log I see, that the trigger was executed.
UPD #1:
It reproduces when I create simple trigger which should start the next minute, after that I shut down all environments (app+db) and then turn it on during the minute when trigger should fire. Check it:
- 16:00:00 create trigger which should fire 16:01:00
- turn off all environments
- wait 16:01:59
- turn on and observe that trigger fire
But if I turn on all environments after 16:02:00 it will not fire trigger. It is very strange behavior. Also, I observe, that in this case trigger was not removed from database.
Solution
There is a property in quartz to control misfire threshold org.quartz.jobStore.misfireThreshold
The number of milliseconds the scheduler will 'tolerate' a trigger to pass its next-fire-time by, before being considered "misfired". The default value (if you don’t make an entry of this property in your configuration) is 60000 (60 seconds).
Link to configuration document
I think if the exceeded time is below 1 minute(default value), the scheduler still considers that job is pending for normal execution. Try playing with that number.
and this is the actual query fired to get the triggers to be executed, note the second condition in the below query is based on the misfireThreshold property
Answered By - vamsikurre
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.