♻️ 抽取 quartz-config.yml,方便使用维护

This commit is contained in:
冷冷 committed 2024-04-22 14:00:55 +08:00
1 parent 9b21069ae5
commit 553f3fbc89
2 files changed
+27

No files matched your search

@@ -17,6 +17,7 @@
package com.pig4cloud.pigx.daemon.quartz.config;
import com.pig4cloud.pigx.common.core.factory.YamlPropertySourceFactory;
import org.quartz.Calendar;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
@@ -31,6 +32,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
@@ -44,6 +46,7 @@ import java.util.Properties;
*/
@EnableAsync
@Configuration
@PropertySource(value = "classpath:quartz-config.yml", factory = YamlPropertySourceFactory.class)
@ConditionalOnClass({ Scheduler.class, SchedulerFactoryBean.class })
@EnableConfigurationProperties({ QuartzProperties.class })
public class PigxQuartzConfig {
@@ -0,0 +1,24 @@
# 如下配置为使用数据库存储定时任务,属性不经常修改,所以不放在 application.yml 中统一管理
spring:
quartz:
properties:
org:
quartz:
scheduler:
instanceName: clusteredScheduler
instanceId: AUTO
jobStore:
class: org.springframework.scheduling.quartz.LocalDataSourceJobStore # 数据库存储
driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate # 数据库代理
tablePrefix: QRTZ_ # 表前缀
isClustered: true # 集群
clusterCheckinInterval: 30000 # 集群检查间隔
useProperties: false
threadPool:
class: org.quartz.simpl.SimpleThreadPool # 线程池
threadCount: 50 # 线程数量
threadPriority: 5 # 线程优先级
threadsInheritContextClassLoaderOfInitializingThread: true # 是否继承类加载器
job-store-type: jdbc # 持久化到数据库
jdbc:
initialize-schema: never # 不初始化表结构