Commit daa59df2 authored by wanghao's avatar wanghao

1 测试 上电后通信 和 最终完成 定时任务功能

parent 3a8765a2
......@@ -55,6 +55,46 @@ spring:
wall:
config:
multi-statement-allow: true
# Quartz持久化配置:cite[1]:cite[5]
quartz:
# 持久化到数据库方式
job-store-type: jdbc
# 初始化数据库架构
jdbc:
initialize-schema: always
# Quartz调度程序属性:cite[1]
properties:
org:
quartz:
scheduler:
# 调度任务实例名称
instanceName: ZhMESDeviceScheduler
# 实例ID,AUTO自动生成
instanceId: AUTO
jobStore:
# JobStore实现类
class: org.quartz.impl.jdbcjobstore.JobStoreTX
# 驱动程序代理类
driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate
# 表名前缀
tablePrefix: QRTZ_
# 是否使用属性文件存储JobDataMaps
useProperties: true
# 错过触发阈值(毫秒)
misfireThreshold: 60000
# 是否启用集群功能
isClustered: false
# 集群检查间隔(毫秒)
clusterCheckinInterval: 15000
# 配置线程池:cite[1]
threadPool:
class: org.quartz.simpl.SimpleThreadPool
# 线程数
threadCount: 10
# 线程优先级
threadPriority: 5
# 线程名称前缀
threadNamePrefix: ZhMESQuartzWorker_
# redis 配置
redis:
# 地址
......
......@@ -55,6 +55,46 @@ spring:
wall:
config:
multi-statement-allow: true
# Quartz持久化配置:cite[1]:cite[5]
quartz:
# 持久化到数据库方式
job-store-type: jdbc
# 初始化数据库架构
jdbc:
initialize-schema: always
# Quartz调度程序属性:cite[1]
properties:
org:
quartz:
scheduler:
# 调度任务实例名称
instanceName: ZhMESDeviceScheduler
# 实例ID,AUTO自动生成
instanceId: AUTO
jobStore:
# JobStore实现类
class: org.quartz.impl.jdbcjobstore.JobStoreTX
# 驱动程序代理类
driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate
# 表名前缀
tablePrefix: QRTZ_
# 是否使用属性文件存储JobDataMaps
useProperties: true
# 错过触发阈值(毫秒)
misfireThreshold: 60000
# 是否启用集群功能
isClustered: false
# 集群检查间隔(毫秒)
clusterCheckinInterval: 15000
# 配置线程池:cite[1]
threadPool:
class: org.quartz.simpl.SimpleThreadPool
# 线程数
threadCount: 10
# 线程优先级
threadPriority: 5
# 线程名称前缀
threadNamePrefix: ZhMESQuartzWorker_
# redis 配置
redis:
host: 127.0.0.1
......
package com.zehong.framework.config.properties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
import javax.sql.DataSource;
import java.util.Properties;
/**
* @author lenovo
* @date 2025/9/23
* @description TODO
*/
@Configuration
public class QuartzConfig {
@Bean
public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) {
SchedulerFactoryBean factory = new SchedulerFactoryBean();
factory.setDataSource(dataSource);
factory.setAutoStartup(true);
factory.setWaitForJobsToCompleteOnShutdown(true);
factory.setOverwriteExistingJobs(true);
Properties props = new Properties();
props.put("org.quartz.scheduler.instanceName", "DeviceScheduler");
props.put("org.quartz.scheduler.instanceId", "AUTO");
props.put("org.quartz.jobStore.misfireThreshold", "60000");
factory.setQuartzProperties(props);
return factory;
}
}
package com.zehong.framework.config.properties;
import com.zehong.system.task.DeviceTaskScheduler;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* @author lenovo
* @date 2025/9/23
* @description TODO
*/
@Component
public class QuartzStartupListener implements ApplicationListener<ApplicationReadyEvent> {
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(QuartzStartupListener.class);
@Resource
private DeviceTaskScheduler deviceTaskScheduler;
@Override
public void onApplicationEvent(ApplicationReadyEvent event) {
log.info("应用启动完成,检查Quartz任务状态...");
// 这里可以添加需要自动恢复的任务检查逻辑
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment