1

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.

4

1 回答 1

2

您可以使用采用 lambda 表达式的重载来定义 cron 计划属性:

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

Quartz 通过检查数据库中的下一个预定时间是否在过去来检测失火。要使场景正常工作,您需要像已经在使用的那样使用持久性存储。

触发时间存储在表 QRTZ_TRIGGERS 的 NEXT_FIRE_TIME 和 PREV_FIRE_TIME 列中。这些值是 .NET DateTime tic。

于 2013-11-06T06:10:54.930 回答