當(dāng)前位置:
首頁(yè) >
前端技术
> javascript
>内容正文
javascript
Spring Boot2.x 整合quartz集群
生活随笔
收集整理的這篇文章主要介紹了
Spring Boot2.x 整合quartz集群
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
springboot2.x支持對(duì)quartz的自動(dòng)配置,引入jar
<!-- spring boot2.x + quartz --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-quartz</artifactId></dependency>數(shù)據(jù)庫(kù)建表
? ? 到官網(wǎng)上下載最新quartz版本,在docs\dbTables文件目錄下找到建表sql腳本
quartz集群相關(guān)配置
springboot會(huì)讀取yml文件內(nèi)容并將值組裝到QuartzProperties類中
spring:quartz:job-store-type: jdbc #數(shù)據(jù)庫(kù)方式j(luò)dbc:initialize-schema: never #不初始化表結(jié)構(gòu)properties:org:quartz:scheduler:instanceId: AUTO #默認(rèn)主機(jī)名和時(shí)間戳生成實(shí)例ID,可以是任何字符串,但對(duì)于所有調(diào)度程序來(lái)說(shuō),必須是唯一的 對(duì)應(yīng)qrtz_scheduler_state INSTANCE_NAME字段#instanceName: clusteredScheduler #quartzSchedulerjobStore:class: org.quartz.impl.jdbcjobstore.JobStoreTX #持久化配置driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate #我們僅為數(shù)據(jù)庫(kù)制作了特定于數(shù)據(jù)庫(kù)的代理useProperties: true #以指示JDBCJobStore將JobDataMaps中的所有值都作為字符串,因此可以作為名稱 - 值對(duì)存儲(chǔ)而不是在BLOB列中以其序列化形式存儲(chǔ)更多復(fù)雜的對(duì)象。從長(zhǎng)遠(yuǎn)來(lái)看,這是更安全的,因?yàn)槟苊饬藢⒎荢tring類序列化為BLOB的類版本問(wèn)題。tablePrefix: qrtz_ #數(shù)據(jù)庫(kù)表前綴misfireThreshold: 60000 #在被認(rèn)為“失火”之前,調(diào)度程序?qū)ⅰ叭萑獭币粋€(gè)Triggers將其下一個(gè)啟動(dòng)時(shí)間通過(guò)的毫秒數(shù)。默認(rèn)值(如果您在配置中未輸入此屬性)為60000(60秒)。clusterCheckinInterval: 5000 #設(shè)置此實(shí)例“檢入”*與群集的其他實(shí)例的頻率(以毫秒為單位)。影響檢測(cè)失敗實(shí)例的速度。isClustered: true #打開群集功能threadPool: #連接池class: org.quartz.simpl.SimpleThreadPoolthreadCount: 10threadPriority: 5threadsInheritContextClassLoaderOfInitializingThread: true?
注意:本文版本2.0.4,隨著版本迭代。屬性參數(shù)會(huì)有變化。如下為2.1.0版本官網(wǎng)文檔說(shuō)明
# QUARTZ SCHEDULER (QuartzProperties) spring.quartz.auto-startup=true # Whether to automatically start the scheduler after initialization. spring.quartz.jdbc.comment-prefix=-- # Prefix for single-line comments in SQL initialization scripts. spring.quartz.jdbc.initialize-schema=embedded # Database schema initialization mode. spring.quartz.jdbc.schema=classpath:org/quartz/impl/jdbcjobstore/tables_@@platform@@.sql # Path to the SQL file to use to initialize the database schema. spring.quartz.job-store-type=memory # Quartz job store type. spring.quartz.overwrite-existing-jobs=false # Whether configured jobs should overwrite existing job definitions. spring.quartz.properties.*= # Additional Quartz Scheduler properties. spring.quartz.scheduler-name=quartzScheduler # Name of the scheduler. spring.quartz.startup-delay=0s # Delay after which the scheduler is started once initialization completes. spring.quartz.wait-for-jobs-to-complete-on-shutdown=false # Whether to wait for running jobs to complete on shutdown.?
總結(jié)
以上是生活随笔為你收集整理的Spring Boot2.x 整合quartz集群的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 锦官城思享会-成都创业与商业CXO闭门会
- 下一篇: SpringBoot + Spring