日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

Spring Boot2.x 整合quartz集群

發布時間:2025/3/16 javascript 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Spring Boot2.x 整合quartz集群 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

springboot2.x支持對quartz的自動配置,引入jar

<!-- spring boot2.x + quartz --><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-quartz</artifactId></dependency>

數據庫建表

? ? 到官網上下載最新quartz版本,在docs\dbTables文件目錄下找到建表sql腳本

quartz集群相關配置

springboot會讀取yml文件內容并將值組裝到QuartzProperties類中

spring:quartz:job-store-type: jdbc #數據庫方式jdbc:initialize-schema: never #不初始化表結構properties:org:quartz:scheduler:instanceId: AUTO #默認主機名和時間戳生成實例ID,可以是任何字符串,但對于所有調度程序來說,必須是唯一的 對應qrtz_scheduler_state INSTANCE_NAME字段#instanceName: clusteredScheduler #quartzSchedulerjobStore:class: org.quartz.impl.jdbcjobstore.JobStoreTX #持久化配置driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate #我們僅為數據庫制作了特定于數據庫的代理useProperties: true #以指示JDBCJobStore將JobDataMaps中的所有值都作為字符串,因此可以作為名稱 - 值對存儲而不是在BLOB列中以其序列化形式存儲更多復雜的對象。從長遠來看,這是更安全的,因為您避免了將非String類序列化為BLOB的類版本問題。tablePrefix: qrtz_ #數據庫表前綴misfireThreshold: 60000 #在被認為“失火”之前,調度程序將“容忍”一個Triggers將其下一個啟動時間通過的毫秒數。默認值(如果您在配置中未輸入此屬性)為60000(60秒)。clusterCheckinInterval: 5000 #設置此實例“檢入”*與群集的其他實例的頻率(以毫秒為單位)。影響檢測失敗實例的速度。isClustered: true #打開群集功能threadPool: #連接池class: org.quartz.simpl.SimpleThreadPoolthreadCount: 10threadPriority: 5threadsInheritContextClassLoaderOfInitializingThread: true

?

注意:本文版本2.0.4,隨著版本迭代。屬性參數會有變化。如下為2.1.0版本官網文檔說明

# 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.

?

總結

以上是生活随笔為你收集整理的Spring Boot2.x 整合quartz集群的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。