Quartz Scheduler: Trigger some jobs on every cluster node and some only once per cluster

旧城冷巷雨未停 提交于 2019-11-29 19:22:23

问题


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

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

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?

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.

Thank you.


回答1:


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.

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.

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.

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.



来源:https://stackoverflow.com/questions/23665688/quartz-scheduler-trigger-some-jobs-on-every-cluster-node-and-some-only-once-per

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!