[英]spring boot quartz not starting in clustered mode
我的 spring 啟動應用程序總是以非集群模式啟動石英。 以下是我的配置:
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
增加了依賴
spring-boot-starter-quartz
有石英工作和觸發器到位。 應用程序啟動並根據 cron 觸發作業。 但石英總是以非集群模式啟動:
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.
我錯過了什么? 我需要以集群模式啟動石英。 任何幫助,不勝感激。 謝謝你。
您可能已經閱讀了這篇關於如何構建集群作業調度程序的文章。
但是,在您的情況下,您使用了
job-store:
class: org.springframework.scheduling.quartz.LocalDataSourceJobStore
但是,您稍后使用的org.quartz.jobStore.isClustered: true
屬性在常見的 spring 引導屬性中不存在。 它是一個特定的屬性,用於特定的 JobStore,即org.quartz.impl.jdbcjobstore.JobStoreTX
如果您的屬性中沒有任何進一步的沖突,只需更改為以下內容即可解決問題。
job-store:
class: org.quartz.impl.jdbcjobstore.JobStoreTX
@Panagiotis Bougioukos 的提示有所幫助。
我不得不將配置job-store:
更改為jobStore:
然后 class class: org.quartz.impl.jdbcjobstore.JobStoreTX
得到尊重,Quartz 以集群模式啟動。
最后
spring.quartz:
job-store-type: jdbc
jdbc:
initialize-schema: never
properties:
org:
quartz:
scheduler:
instanceId: AUTO
instanceName: myQuartzScheduler
jobStore:
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
並定義quartzDataSource
幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.