-
|
I have just found a question in SO, that I think it remains unanswered: I am starting with Quartz.Net, so maybe this is not the right way to achieve this behaviour. I have a long running Job (3 seconds) that repeats every 10 seconds. I also want to be able to trigger a fire-and-forget same job execution in that "free" time. But if the trigger starts when the job is already executing (say, during the first 3 seconds) then I don't want to execute at all when it would be able to do it. The job is marked with both Right now, if I schedule the fire-and-forget trigger during the execution of the job during the first 3 seconds, it executes as soon as it can (at the beginning of the 4th second). To have full control on the fire-and-forget trigger, I am not using the IScheduler.TriggerJob method, instead I do: But... the behavior is exactly the same... it executes when it is able to do it. I think the original author of the SO question was asking exactly this same matter, as it is titled "How to prevent Quartz.Net misfired job from retrying". By the way, the behavior of the repeating trigger is the same... if the fire-and-forget is executing while the repeating one should fire again... it does not skip the execution (I have a WithMisfireHandlingInstructionNextWithRemainingCount policy, not the "now" alternative) and also executes immediately after the fire-and-forget trigger. Maybe I am missing something here... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Oops, I think I now understand. The problem with my case is that the This means that any Job not executing within a frame of 60 seconds from the desired starting time, WILL NOT be marked as "misfired", and so the misfired policy I set was not executing at all. The Scheduler just ran the Job as soon as it could. To achieve my desired behavior I had to do:
So, a simplified working code would be: And then, the fire-and-forget trigger (on demand): |
Beta Was this translation helpful? Give feedback.
Oops, I think I now understand. The problem with my case is that the
quartz.jobStore.misfireThresholdconfiguration property (also set with .WithMisfireThreshold in the SchedulerBuilder) is set to 60 seconds by default.This means that any Job not executing within a frame of 60 seconds from the desired starting time, WILL NOT be marked as "misfired", and so the misfired policy I set was not executing at all. The Scheduler just ran the Job as soon as it could.
To achieve my desired behavior I had to do:
.WithMisfireThreshold(TimeSpan.FromSeconds(1))(or less).WithMisfireHandlingInstructionNextWithRemainingCount()