سؤال

Im using Quartz.Net in a MVC application, installed with NuGet.

And have a trigger like this:

ITrigger trigger = TriggerBuilder.Create()
                    .WithIdentity("trigger1", "group1")                              
                    .WithCronSchedule("0 0 4 1 * ?")                                
                    .Build();

How can i add a Misfire Instruction so that if the server happens to be down at the time when the job was supposed to be triggered the event is triggered as soon as the server is up again?

And how would that be possible, does Quarts keep track of last time the event was triggered? I cannot find a database or file where this could be saved.

هل كانت مفيدة؟

المحلول

You can define cron schedule attributes using an overload that takes lambda expression:

ITrigger trigger = TriggerBuilder.Create()
        .WithIdentity("trigger1", "group1")
        .WithCronSchedule("0 0 4 1 * ?", x => x.WithMisfireHandlingInstructionFireAndProceed())
        .Build();

Quartz detects misfires by checking whether next scheduled time in database is in the past. For the scenario to work you need to use the persistent storage like you already are doing.

The fire times are stored in table QRTZ_TRIGGERS in columns NEXT_FIRE_TIME and PREV_FIRE_TIME. These values are .NET DateTime tics.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top