Quartz Scheduler:在每个集群节点上触发一些作业,每个集群只触发一些作业 [英] Quartz Scheduler: Trigger some jobs on every cluster node and some only once per cluster

查看:1227
本文介绍了Quartz Scheduler:在每个集群节点上触发一些作业,每个集群只触发一些作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在集群环境中使用Quartz Scheduler作为Spring bean。

I am using Quartz Scheduler as a Spring bean in a clustered environment.

我有一些使用@NotConcurrent注释的作业,它们每个集群运行一次(即仅在一个节点中,只在一个线程中。)

I have some jobs annotated with @NotConcurrent and they are running once per cluster (i.e. only in one node, only in one thread).

现在我需要在集群的每个节点上运行一个作业。
我删除了@NotConcurrent注释,但它只在一台机器上的每个线程上运行。它不会在其他节点上被触发。

Now I need to run one job on every node of the cluster. I removed the @NotConcurrent annotation, but it only run on every thread on one machine. It does not get fired on other nodes.

我应该用什么来注释作业?

What should I annotate the job with?

示例:Job1 NotConcurrent annotated安排在午夜=>它每隔午夜只在1台机器上启动。 Job2注释安排在午夜=>它每隔午夜在每台机器上启动。

Example: Job1 NotConcurrent annotated is scheduled at midnight => It fires only on 1 machine every midnight. Job2 annotated scheduled at midnight => It fire on every machine every midnight.

谢谢。

推荐答案

AFAIK Quartz作业总是在Quartz选择的单个节点上执行。 @NonConcurrent注释仅阻止Quartz在特定节点上同时执行相同的作业。

AFAIK Quartz job are always executed on a single node that is picked by Quartz. The @NonConcurrent annotation only prevents Quartz from executing the same job concurrently on a particular node.

换句话说,不能让Quartz同时在多个节点上执行作业。它总是选择一个节点来执行作业。

In other words, you cannot make Quartz execute a job on multiple nodes concurrently. It always picks a single node to execute the job on.

要实现您描述的内容,您可能需要多个作业(使用相同的作业类且没有关联的触发器)。然后,您将需要实现某种可以远程连接的协调器作业,例如,通过JMX或RMI,到个别节点并手动触发作业。

To realize what you describe, you may need multiple jobs (using the same job class and without associated triggers). Then you will need to implement some sort of an orchestrator job that would remotely connect, e.g. via JMX or RMI, to individual nodes and trigger the jobs manually.

您可能需要查看我们的产品QuartzDesk( www.quartzdesk.com )提供一个Web服务,提供单端点,您可以通过该端点连接到各个Quartz调度程序实例,例如,触发它们上的作业。

You may want to check our product QuartzDesk (www.quartzdesk.com) that provides a web-service that provides a single-endpoint through which you can connect to individual Quartz scheduler instances and, for example, trigger jobs on them.

这篇关于Quartz Scheduler:在每个集群节点上触发一些作业,每个集群只触发一些作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆