I am new to quartz scheduling and thus I read a lot of about how only one job runs in a clustered environment because of following quartz properties:
spring.scheduler.instanceName - $UniqueName
spring.scheduler.instanceId - AUTO
spring.scheduler.jobStoreClass - XYZ
spring.scheduler.jobStoreDriverDelegateClass - XYZ
spring.scheduler.jobStoreIsClustered - true
Here's my understanding: The prevention of running multiple jobs when only one job should be running, happens at database level. The database decides on the basis of instanceID and instanceName whether the job is already running or not. If not, then the first trigger reaching database, triggers the job.
BUT this makes sense when we are connecting to only one URL of database or let's say one datacenter of database.
How do we make sure only one job runs in the below scenario:
- 4 quartz schedulers running on dc1 connected to dc1 database.
- 4 quartz schedulers running on dc2 connected to dc2 database.
Please note that dc1 database and dc2 database will be in sync after a few milliseconds.
Please let me know. Thanks in advance!
question from:
https://stackoverflow.com/questions/65837323/single-job-to-run-in-a-clustered-quartz-scheduler-connected-to-multi-datacenter 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…