使用多个实例中断石英中的作业

Interrupting a job in quartz with multiple instances

我有 5 个在集群模式下使用 quartz 的应用程序实例,它们都具有 quartz 调度程序 运行。 (使用 postgresql)

org.quartz.jobStore.isClustered:true
org.quartz.scheduler.instanceName: myInstanceName
org.quartz.scheduler.instanceId: AUTO

所以我有一个工作可以启动并执行一些操作,必要时使用新的计划时间更新自身,否则会自行删除。 (一个作业只能包含一个触发器。)

该应用程序有一个 UI 界面,允许用户取消作业。

当中断命令从UI发送时;

如果作业当前不工作;我可以暂停作业或取消。

如果当时我的工作正在工作,我怎样才能用正确的实例停止工作并获得工作的当前状态?基本上我想在那一刻捕捉并保存那一刻的数据,哪个用户实际上是中断时刻

scheduler.interrupt(jobKey) 是否会中断我正确实施 InterruptableJob 的作业?

scheduler.interrupt() 是否确切知道当前应 运行 作业的实例并找到正确的实例并获得作业的正确状态?

你能纠正我吗,或者我应该走哪条路?

quartz 中的中断方法实现和 getCurrentlyExecutingJobs() 不支持集群,

这意味着该方法必须在执行该作业的实例上 运行,换句话说,只有当前实例中具有指定作业键 运行ning 的作业才会被中断。

可以向所有 运行ning 石英实例广播中断请求,以取消所有 运行ning 作业实例。

来自:https://www.quartz-scheduler.org/api/2.1.7/org/quartz/Scheduler.html#interrupt(org.quartz.JobKey)

This method is not cluster aware. That is, it will only interrupt instances of the identified InterruptableJob currently executing in this Scheduler instance, not across the entire cluster.