1

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?

dae
  • 589
  • 2
  • 6
  • 20

1 Answers1

2

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

user06062019
  • 681
  • 4
  • 9
  • Two more questions: 1. As the [document](http://www.quartz-scheduler.org/documentation/2.4.0-SNAPSHOT/introduction.html) says, there are four `Runtime Environments ` modes. Which mode does your description beyong to? 2. Is there a need to use `DisallowConcurrentExecution` in clustering mode? – dae Oct 24 '19 at 05:52
  • 1 The description belongs to all types of environment as long as all the service instances on which quartz are running share the same database.2 There is no need of using DisallowConcurrentExecution as this annotation can be used in RamJobStore which doesn't support clustering. – user06062019 Oct 24 '19 at 17:20
  • You can check this link as well https://stackoverflow.com/questions/35292420/quartz-2-2-multi-scheduler-and-disallowconcurrentexecution – user06062019 Oct 24 '19 at 17:32
  • Awesome answers. Thank you! @user06062019 – dae Oct 25 '19 at 01:12