如何使多个实例同时而不是同时执行同一个作业
我有 4 个 Quartz Server 实例。所有实例都指向一个 ADO JobStore。我想做的就是让每个 Quartz 实例同时执行相同的作业。
我希望它足够清楚。
I have 4 instances of Quartz Server. All of the instances point to one ADO JobStore. All I want to do is to make each Quartz instance execute the same job at the same time.
I hope it's clear enough.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
开箱即用不支持此功能。每当触发器触发时,它只能被一个实例消耗。您可以触发 4 个触发器,但不能保证该作业不会在一个实例上运行两次。
如果您希望每个实例触发一次作业,那么您将必须设置 4 个单独的作业存储。
This isn't supported out of the box. Whenever a trigger fires, it can only be consumed by one instance. You could fire 4 triggers, but it is not guaranteed that the job will not run twice on one instance.
If you want each instance to fire the job once, then you will have to set up 4 separate job stores.
我所做的(在 Quartz.NET 2.4.1 中)是我有多个相同的调度程序实例,它们仅在调度程序实例名称(
quartz.scheduler.instanceName
)上有所不同。他们注册相同的作业和触发器。由于调度程序实例名称不同,作业和触发器在作业存储中会重复(调度程序名称是JobStoreTX
每个表中主键的一部分)。这会导致逻辑上相同的触发器同时在所有调度程序实例上触发。不过,它们实际上是单独的触发器,因此每个触发器都会单独处理失火等。What I do (in Quartz.NET 2.4.1) is that I have multiple identical scheduler instances, which only differ in scheduler instance name (
quartz.scheduler.instanceName
). They register identical jobs and triggers. Because of different scheduler instance names, the jobs and triggers are duplicated in the job store (scheduler name is part of the primary key in every table ofJobStoreTX
). This causes logically the same triggers to fire on all scheduler instances at the same time. They are actually separate triggers, though, so each will handle misfires etc separately.