问题
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