My spring boot application always starts quartz in non clustered mode. Below is my configurations:
spring.quartz:
job-store-type: jdbc
jdbc:
initialize-schema: never
properties:
org:
quartz:
scheduler:
instanceId: AUTO
instanceName: myQuartzScheduler
job-store:
dataSource: quartzDataSource
class: org.springframework.scheduling.quartz.LocalDataSourceJobStore
driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate
useProperties: false
tablePrefix: QRTZ_
misfireThreshold: 60000
clusterCheckinInterval: 5000
isClustered: true
threadPool:
class: org.quartz.simpl.SimpleThreadPool
threadCount: 10
threadPriority: 5
threadsInheritContextClassLoaderOfInitializingThread: true
added dependency
spring-boot-starter-quartz
have quartz job and trigger in place. Application starts and the job gets fired as per the cron. but quartz always starts in non clustered mode:
2022-07-29 11:10:09.810 INFO 86257 --- [ main] o.s.s.quartz.LocalDataSourceJobStore : JobStoreCMT initialized.
2022-07-29 11:10:09.810 INFO 86257 --- [ main] org.quartz.core.QuartzScheduler : Scheduler meta-data: Quartz Scheduler (v2.3.2) 'myQuartzScheduler' with instanceId 'NON_CLUSTERED'
Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
NOT STARTED.
Currently in standby mode.
Number of jobs executed: 0
Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
Using job-store 'org.springframework.scheduling.quartz.LocalDataSourceJobStore' - which supports persistence. and is not clustered.
What did I miss folks? I need to start quartz in clustered mode. Any help, appreciated. Thank you.
CodePudding user response:
You have probably followed this article on how to build the clustered job scheduler.
In your case however you have used the
job-store:
class: org.springframework.scheduling.quartz.LocalDataSourceJobStore
The property however org.quartz.jobStore.isClustered: true
that you later use, does not exist in common spring boot properties. It is a specific property, that is used from a specific JobStore, namely the org.quartz.impl.jdbcjobstore.JobStoreTX
If you don't have any further conflicts in your properties, just changing into the following should fix the issue.
job-store:
class: org.quartz.impl.jdbcjobstore.JobStoreTX
CodePudding user response:
The hint from @Panagiotis Bougioukos helped.
I had to change the configuration job-store:
to jobStore:
then the class class: org.quartz.impl.jdbcjobstore.JobStoreTX
was honoured and Quartz started in clustered mode.
Finally
spring.quartz:
job-store-type: jdbc
jdbc:
initialize-schema: never
properties:
org:
quartz:
scheduler:
instanceId: AUTO
instanceName: myQuartzScheduler
job-store:
dataSource: quartzDataSource
.
.
dataSource.quartzDataSource:
driver: com.mysql.cj.jdbc.Driver
URL: jdbc:mysql://${database.host:localhost}:${database.port:3306}/${database.name:mySchema}
user: myUser
password: ******
provider: hikaricp
and defining the quartzDataSource
helped.