配置为每天运行一次的 Quartz.NET 作业在第一天可以运行,但在随后的几天无法触发
我已经在我的 asp.net 应用程序中配置了quartz.net,并且我有一个作业设置为每天凌晨 1 点运行。如果我更改 job-config.xml 文件以使作业在 2 分钟内运行,则更改会自动生效,而无需重新启动应用程序池,并且作业将被启动。但是,如果我恢复更改以再次在凌晨 1 点启动该作业,它似乎不会启动。对我来说,明显的原因是应用程序池或 IIS 已重新启动,这将导致我的 asp.net 应用程序关闭(实际上关闭quartz.net,因为它是同一 asp.net 的一部分)。 net 进程),但为了测试quartz.net 是否仍在运行,没有任何 iisreset
或应用程序池回收,我再次更改 job-config.xml 文件以在 2 分钟内再次启动,然后作业运行,所以它似乎没有发生应用程序池回收或 IIS 重置的情况 - 我不明白。
我希望保持该作业在我的 asp.net 应用程序下运行,而无需创建额外的 Windows 服务,因此我们将不胜感激。下面是我的quartz.net 配置文件的片段。
<job>
<job-detail>
<name>xjob</name>
<group>MyJobs</group>
<description>blah blah</description>
<job-type>yyy.xxx,yyy</job-type>
<volatile>false</volatile>
<durable>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>
谢谢
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>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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为有几件事正在发生。正如您所提到的,如果您在 ASP.NET 下运行调度程序,该进程可能会被回收,并且您的调度程序可能无法在应该运行的作业时运行该作业。如果在给定时间运行作业很重要,那么您需要将 Quartz.net 设置为服务。
缺少的另一件事是,我认为您正在使用 RAM 作业撕裂,这意味着当调度程序重新启动时,它会重新安排作业,因此在您的情况下,它不会再次触发,直到 1。如果调度程序未运行为 1 时,即使调度程序重新启动(依此类推),作业也不会触发。如果您使用 ADO 作业存储,那么至少触发器将被保留,并且一旦调度程序再次启动并检测到失火,作业将运行。
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.