开发者

Quartz.NET job configurared to run once daily works the first day but fails to fire on subsequent days

开发者 https://www.devze.com 2023-04-08 17:16 出处:网络
I\'ve configured quartz.net within my asp.net application and I have a job set to run daily at 1am. If I change the job-config.xml file to have the job run in 2 minutes time, the change is automatical

I've configured quartz.net within my asp.net application and I have a job set to run daily at 1am. If I change the job-config.xml file to have the job run in 2 minutes time, the change is automatically picked up without restarting the app-pool, and the job is fired off. However, if I revert the change to have the job fire off at 1am in the morning again, it doesn't seem to fire off. The obvious reason to me would be that either the app-pool or IIS has been restarted, which would have caused my asp.net app to shutdown (in effect shutting down quartz.net as it's part-and-parcel of the same asp.net process), but to test whether quartz.net is still running, without any iisreset or app-pool recycle, I change the job-config.xml file again to fire off within 2 minutes again and the job runs, so it doesn't seem to be the case where an app-pool recycle or IIS reset has occurred - I don't understand.

I would like to keep the job running under my asp.net application without having to create an additional windows service, so any help would greatly be appreciated. Below is a snippet of my quartz.net config file.

<job>
<job-detail>
  <name>xjob</name>
  <group>MyJobs</group>
  <description>blah blah</description>
  <job-type>yyy.xxx,yyy</job-type>
  <volatile>false</volatile>
  <durable&开发者_如何学Gogt;true</durable>
  <recover>false</recover>      
</job-detail>
<trigger>
  <cron>
    <name>xJobTrigger</name>
    <group>MyJobs</group>
    <description>blah blah</description>
    <job-name>xJob</job-name>
    <job-group>MyJobs</job-group>
    <cron-expression>0 0 1 * * ?</cron-expression>
  </cron>      
</trigger>

Thank you


I think there are a couple of things going on. As you mention, if you run the scheduler under asp.net, the process might get recycled and your scheduler might not be available to run the job when it is supposed to run. If having the job run at a give time is important, then you need to set up Quartz.net as a service.

The other thing that is missing is that I think you are using a RAM jobs tore, which means that when the scheduler restarts, it reschedules the job, so in your case, it will not fire again until 1. If the scheduler is not running at 1, then the job won't fire, even if the scheduler restarts (and so on). If you use an ADO job store, then at least the trigger will get persisted and the job will run once the scheduler starts again and the misfire is detected.

0

精彩评论

暂无评论...
验证码 换一张
取 消