Search code examples
spring-bootspring-batchquartz-scheduler

How to create simple hello world using quartz scheduler and spring boot in clustering mode?


I wanted to create a quartz job on clustering mode using spring boot I am using following quartz.properties and I have created 2 cron jobs for same time is it going to work in cluster or not ?

#===================================================
#quartz.properties
#===================================================

#===================================================
#scheduler name will be "MyScheduler"
#===================================================
 org.quartz.scheduler.instanceName=TestScheduler
 org.quartz.scheduler.instanceId=AUTO

#===================================================
#maximum of 3 jobs can be run simultaneously
#===================================================
 org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
 org.quartz.threadPool.makeThreadsDaemons = true
 org.quartz.threadPool.threadCount: 50
 org.quartz.threadPool.threadPriority: 5

#===================================================
# Configure JobStore
#===================================================
 org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.oracle.OracleDelegate
org.quartz.jobStore.useProperties=true
org.quartz.jobStore.misfireThreshold=25000
org.quartz.jobStore.tablePrefix=QRTZ_
org.quartz.jobStore.isClustered=false 
org.quartz.jobStore.dataSource = myDS
org.quartz.jobStore.isClustered=true

#===================================================
#Quartz dataSource
#===================================================
org.quartz.dataSource.myDS.driver=oracle.jdbc.pool.OracleDataSource
org.quartz.dataSource.myDS.URL=jdbc:oracle:thin:@localhost:1521:XE
org.quartz.dataSource.myDS.user=oracle
org.quartz.dataSource.myDS.password =oracle
org.quartz.dataSource.myDS.maxConnections=5
org.quartz.dataSource.myDS.validationQuery=select 1

Solution

  • To run quartz jobs in a clustered environment, org.quartz.jobStore.isClustered should be set and org.quartz.scheduler.instanceId should be AUTO. I can see your quartz property file have two entries for org.quartz.jobStore.isClustered