Does Quartz support execute once on multiple node?

為{幸葍}努か 提交于 2021-02-17 02:46:05

问题


In my scenario, Quartz will run embedded within my web application which will be deployed on two nodes. Could I schedule a task and make it execute only once on the two nodes? Is DisallowConcurrentExecution annotation used for this purpose?

For example, if I schedule a task with a per hour trigger, could the total execute count of the task in a day on the two node be 24 instead of 48?


回答1:


You can set the quartz to be in clustered mode.The main requirement for it is both the instances of your service should share the same database as quartz does clustering based on database. If you use the clustering mechanism in your case 24 jobs will be executed.These are some of the properties that you have to use.

org.quartz.scheduler.instanceName = MyClusteredScheduler
org.quartz.scheduler.instanceId = AUTO
org.quartz.jobStore.isClustered = true
org.quartz.jobStore.clusterCheckinInterval=20000

Refer documentation at http://www.quartz-scheduler.org/documentation/quartz-1.8.6/configuration/ConfigJDBCJobStoreClustering.html



来源:https://stackoverflow.com/questions/58513804/does-quartz-support-execute-once-on-multiple-node

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