Quartz.Net - 延迟一个简单的触发器启动
我在 Quartz 中设置了一些作业,以按设定的时间间隔运行。问题是,当服务启动时,它会尝试立即启动所有作业...有没有办法使用 .xml 配置为每个作业添加延迟?
以下是 2 个作业触发器示例:
<simple>
<name>ProductSaleInTrigger</name>
<group>Jobs</group>
<description>Triggers the ProductSaleIn job</description>
<misfire-instruction>SmartPolicy</misfire-instruction>
<volatile>false</volatile>
<job-name>ProductSaleIn</job-name>
<job-group>Jobs</job-group>
<repeat-count>RepeatIndefinitely</repeat-count>
<repeat-interval>86400000</repeat-interval>
</simple>
<simple>
<name>CustomersOutTrigger</name>
<group>Jobs</group>
<description>Triggers the CustomersOut job</description>
<misfire-instruction>SmartPolicy</misfire-instruction>
<volatile>false</volatile>
<job-name>CustomersOut</job-name>
<job-group>Jobs</job-group>
<repeat-count>RepeatIndefinitely</repeat-count>
<repeat-interval>43200000</repeat-interval>
</simple>
如您所见,有 2 个触发器,第一个触发器每天重复,下一个触发器每天重复两次。
我的问题是,我希望第一个或第二个作业在另一个作业几分钟后开始...(因为它们最终都访问相同的 API,并且我不想超载请求)
是否有重复延迟或优先属性?我找不到任何文档这么说..
I have a few jobs setup in Quartz to run at set intervals. The problem is though that when the service starts it tries to start all the jobs at once... is there a way to add a delay to each job using the .xml config?
Here are 2 job trigger examples:
<simple>
<name>ProductSaleInTrigger</name>
<group>Jobs</group>
<description>Triggers the ProductSaleIn job</description>
<misfire-instruction>SmartPolicy</misfire-instruction>
<volatile>false</volatile>
<job-name>ProductSaleIn</job-name>
<job-group>Jobs</job-group>
<repeat-count>RepeatIndefinitely</repeat-count>
<repeat-interval>86400000</repeat-interval>
</simple>
<simple>
<name>CustomersOutTrigger</name>
<group>Jobs</group>
<description>Triggers the CustomersOut job</description>
<misfire-instruction>SmartPolicy</misfire-instruction>
<volatile>false</volatile>
<job-name>CustomersOut</job-name>
<job-group>Jobs</job-group>
<repeat-count>RepeatIndefinitely</repeat-count>
<repeat-interval>43200000</repeat-interval>
</simple>
As you see there are 2 triggers, the first repeats every day, the next repeats twice a day.
My issue is that I want either the first or second job to start a few minutes after the other... (because they are both in the end, accessing the same API and I don't want to overload the request)
Is there a repeat-delay or priority property? I can't find any documentation saying so..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我知道您是通过 XML 执行此操作,但在代码中您可以将
StartTimeUtc
设置为延迟 30 秒,如下所示...I know you are doing this via XML but in code you can set the
StartTimeUtc
to delay say 30 seconds like this...对于您的 XML 文件来说,这并不是一个完美的答案 - 但通过代码,您可以在构建触发器时使用 StartAt 扩展方法。
This isn't exactly a perfect answer for your XML file - but via code you can use the StartAt extension method when building your trigger.
您现在可能已经看到了这一点,但是可以链接作业,尽管不支持开箱即用。
http://quartznet.sourceforge.net/faq.html#howtochainjobs
You've probably already seen this by now, but it's possible to chain jobs, though it's not supported out of the box.
http://quartznet.sourceforge.net/faq.html#howtochainjobs