集群滚动更新时,如何给需要启动运行的Quartz集群添加新的Job?

How to add a new Job to a Quartz cluster that needs to start running during the rolling update of the cluster?

我们在几个应用程序节点上集群了 Quartz 调度程序 运行ner。应用节点需要更新,为了高可用,更新是滚动更新的。

与更新一起,我们需要添加一个新作业,并且该作业需要立即启动 运行ning - 即它不能等到所有节点都已更新。问题是我 can't control which node will run the new job, and if one of the old nodes runs the job, the job instantiation will faill (with a ClassNotFoundException), the 而这份工作不会再 运行。

此问题的一个解决方案是进行两次更新:一次在所有节点中添加 class,一次添加触发器。反对这种方法的主要原因是我们的操作程序不支持这种方法。

那么是否还有一种方法可以安排新作业并通过一次更新使其 运行 可靠?

我刚刚试过了,结果是 Quartz 在尝试获取触发器时得到了一个 ClassCastException。异常被包装到 JobPersistenceException 中,触发器处于 WAITING 状态。

因此,尽管这可能会导致旧节点之一出现错误日志条目,但 Quartz 不会让触发器处于非工作状态。