diff --git a/orion-ops-framework/orion-ops-framework-common/src/main/java/com/orion/ops/framework/common/constant/AutoConfigureOrderConst.java b/orion-ops-framework/orion-ops-framework-common/src/main/java/com/orion/ops/framework/common/constant/AutoConfigureOrderConst.java index 15cae06a..14d56b6b 100644 --- a/orion-ops-framework/orion-ops-framework-common/src/main/java/com/orion/ops/framework/common/constant/AutoConfigureOrderConst.java +++ b/orion-ops-framework/orion-ops-framework-common/src/main/java/com/orion/ops/framework/common/constant/AutoConfigureOrderConst.java @@ -25,19 +25,21 @@ public interface AutoConfigureOrderConst { int FRAMEWORK_LOG = Integer.MIN_VALUE + 1500; - int FRAMEWORK_JOB = Integer.MIN_VALUE + 1600; + int FRAMEWORK_SWAGGER = Integer.MIN_VALUE + 1600; - int FRAMEWORK_SWAGGER = Integer.MIN_VALUE + 1700; + int FRAMEWORK_DATASOURCE = Integer.MIN_VALUE + 1700; - int FRAMEWORK_DATASOURCE = Integer.MIN_VALUE + 1800; + int FRAMEWORK_MYBATIS = Integer.MIN_VALUE + 1800; - int FRAMEWORK_MYBATIS = Integer.MIN_VALUE + 1900; + int FRAMEWORK_REDIS = Integer.MIN_VALUE + 1900; - int FRAMEWORK_REDIS = Integer.MIN_VALUE + 2000; + int FRAMEWORK_REDIS_CACHE = Integer.MIN_VALUE + 1950; - int FRAMEWORK_REDIS_CACHE = Integer.MIN_VALUE + 2050; + int FRAMEWORK_STORAGE = Integer.MIN_VALUE + 2000; - int FRAMEWORK_STORAGE = Integer.MIN_VALUE + 2100; + int FRAMEWORK_JOB = Integer.MIN_VALUE + 2100; + + int FRAMEWORK_JOB_QUARTZ = Integer.MIN_VALUE + 2150; int FRAMEWORK_MONITOR = Integer.MIN_VALUE + 2200; diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-job/pom.xml b/orion-ops-framework/orion-ops-spring-boot-starter-job/pom.xml index c2eb65e7..27da527d 100644 --- a/orion-ops-framework/orion-ops-spring-boot-starter-job/pom.xml +++ b/orion-ops-framework/orion-ops-spring-boot-starter-job/pom.xml @@ -32,6 +32,14 @@ org.springframework.boot spring-boot-starter-quartz + + + + com.alibaba + druid-spring-boot-starter + provided + + \ No newline at end of file diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-job/src/main/java/com/orion/ops/framework/job/config/OrionQuartzAutoConfiguration.java b/orion-ops-framework/orion-ops-spring-boot-starter-job/src/main/java/com/orion/ops/framework/job/config/OrionQuartzAutoConfiguration.java new file mode 100644 index 00000000..ae14d60d --- /dev/null +++ b/orion-ops-framework/orion-ops-spring-boot-starter-job/src/main/java/com/orion/ops/framework/job/config/OrionQuartzAutoConfiguration.java @@ -0,0 +1,54 @@ +package com.orion.ops.framework.job.config; + +import com.orion.ops.framework.common.constant.AutoConfigureOrderConst; +import org.quartz.Scheduler; +import org.springframework.boot.autoconfigure.AutoConfiguration; +import org.springframework.boot.autoconfigure.AutoConfigureOrder; +import org.springframework.context.annotation.Bean; +import org.springframework.scheduling.quartz.SchedulerFactoryBean; +import org.springframework.scheduling.quartz.SpringBeanJobFactory; + +import javax.sql.DataSource; + +/** + * quartz 配置 + * + * @author Jiahang Li + * @version 1.0.0 + * @since 2024/3/27 0:58 + */ +@AutoConfiguration +@AutoConfigureOrder(AutoConfigureOrderConst.FRAMEWORK_JOB_QUARTZ) +public class OrionQuartzAutoConfiguration { + + /** + * @return 任务工厂 + */ + @Bean + public SpringBeanJobFactory jobFactory() { + return new SpringBeanJobFactory(); + } + + /** + * @param dataSource dataSource + * @param jobFactory jobFactory + * @return 调度器工厂 + */ + @Bean + public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource, SpringBeanJobFactory jobFactory) { + SchedulerFactoryBean factory = new SchedulerFactoryBean(); + factory.setDataSource(dataSource); + factory.setJobFactory(jobFactory); + return factory; + } + + /** + * @param schedulerFactoryBean 调度器工厂 + * @return 调度器 + */ + @Bean(initMethod = "start") + public Scheduler scheduler(SchedulerFactoryBean schedulerFactoryBean) { + return schedulerFactoryBean.getScheduler(); + } + +} diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-job/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/orion-ops-framework/orion-ops-spring-boot-starter-job/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports index 260d68dc..e4d17a55 100644 --- a/orion-ops-framework/orion-ops-spring-boot-starter-job/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +++ b/orion-ops-framework/orion-ops-spring-boot-starter-job/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -1 +1,2 @@ -com.orion.ops.framework.job.config.OrionSchedulerAutoConfiguration \ No newline at end of file +com.orion.ops.framework.job.config.OrionSchedulerAutoConfiguration +com.orion.ops.framework.job.config.OrionQuartzAutoConfiguration \ No newline at end of file diff --git a/orion-ops-launch/src/main/resources/application.yaml b/orion-ops-launch/src/main/resources/application.yaml index 5f7905c8..ca047f0d 100644 --- a/orion-ops-launch/src/main/resources/application.yaml +++ b/orion-ops-launch/src/main/resources/application.yaml @@ -64,6 +64,34 @@ spring: output: ansi: enabled: DETECT + quartz: + job-store-type: JDBC + overwrite-existing-jobs: false + jdbc: + initialize-schema: ALWAYS + properties: + org: + quartz: + scheduler: + # 实例 ID + instanceId: AUTO + instanceName: quartzScheduler + jobStore: + # 持久化配置 + class: org.quartz.impl.jdbcjobstore.JobStoreTX + driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate + useProperties: false + tablePrefix: QRTZ_ + misfireThreshold: 60000 + clusterCheckinInterval: 5000 + # 打开群集功能 + isClustered: false + #连接池 + threadPool: + class: org.quartz.simpl.SimpleThreadPool + threadCount: 10 + threadPriority: 5 + threadsInheritContextClassLoaderOfInitializingThread: true boot: admin: context-path: /admin @@ -112,7 +140,7 @@ logging: logback: rollingpolicy: clean-history-on-start: false - file-name-pattern: ${logging.file.path}/rolling/orion-ops-rolling-%d{yyyy-MM-dd}.%i.gz + file-name-pattern: ${logging.file.path}/rolling/rolling-%d{yyyy-MM-dd}.%i.gz max-history: 30 max-file-size: 16MB total-size-cap: 0B @@ -156,6 +184,7 @@ orion: session-idle-timeout: 1800000 swagger: # swagger 配置 + author: lijiahang title: orion-ops-pro 运维平台 description: 一站式运维服务平台 version: ${orion.version}