これは私のクォーツ構成です:
<quartz>
<add key="quartz.scheduler.instanceName" value="EmailScheduler" />
<!-- Configure Thread Pool -->
<add key="quartz.threadPool.type" value="Quartz.Simpl.SimpleThreadPool, Quartz" />
<add key="quartz.threadPool.threadCount" value="10" />
<add key="quartz.threadPool.threadPriority" value="Normal" />
<!-- Configure Job Store -->
<add key="quartz.jobStore.misfireThreshold" value="60000" />
<add key="quartz.jobStore.type" value="Quartz.Impl.AdoJobStore.JobStoreTX, Quartz" />
<add key="quartz.jobStore.driverDelegateType" value="Quartz.Impl.AdoJobStore.StdAdoDelegate, Quartz" />
<add key="quartz.jobStore.dataSource" value="default" />
<add key="quartz.jobStore.lockHandler.type" value="Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz" />
<add key="quartz.dataSource.default.provider" value="SqlServer-20" />
<add key="quartz.dataSource.default.connectionString" value="data source= ......" />
<add key="quartz.jobStore.tablePrefix" value="QRTZ_" />
</quartz>
ここに私のIInterruptableJob
:
public class JobC : Quartz.IInterruptableJob
{
public void Interrupt()
{
Console.WriteLine("Job Interrupt() called at " + DateTime.Now);
}
public void Execute(IJobExecutionContext context)
{
// what code I should write here to detect misfires???
Console.WriteLine("FireTime at " + context.FireTimeUtc.Value + " PreviousFireTime at:" + (context.PreviousFireTimeUtc.HasValue ? context.PreviousFireTimeUtc.Value.ToString() : "NULL"));
}
}
これが私の仕事とトリガーです:
var job = JobBuilder.Create<JobC>().WithIdentity(new JobKey("JobC")).RequestRecovery(true).Build();
var trigger = TriggerBuilder.Create()
.WithSimpleSchedule(x => x
.RepeatForever()
.WithIntervalInSeconds(2)
// I'm ignoring misfires here, but seems it doesn't work!
.WithMisfireHandlingInstructionIgnoreMisfires())
.StartNow()
.Build();
var scheduler = new Quartz.Impl.StdSchedulerFactory().GetScheduler();
scheduler.Start();
scheduler.ScheduleJob(job, trigger);
scheduler.PauseAll()
すべてのジョブの一時停止を呼び出した後scheduler.ResumeAll()
、失敗したすべての火災を呼び出した後、解雇されます! しかし、私はそれらを無視して、これから続けたいと思っています。
前もって感謝します。