完成运行时状态上报功能

This commit is contained in:
柏码の讲师 2023-12-01 17:09:48 +08:00
parent 81622001ce
commit 4bb27f6d5c

View File

@ -0,0 +1,36 @@
package com.example.config;
import com.example.task.MonitorJobBean;
import lombok.extern.slf4j.Slf4j;
import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import oshi.SystemInfo;
@Slf4j
@Configuration
public class QuartzConfiguration {
@Bean
public SystemInfo info(){
return new SystemInfo();
}
@Bean
public JobDetail jobDetailFactoryBean() {
return JobBuilder.newJob(MonitorJobBean.class)
.withIdentity("monitor-task")
.storeDurably()
.build();
}
@Bean
public Trigger cronTriggerFactoryBean(JobDetail detail) {
CronScheduleBuilder cron= CronScheduleBuilder.cronSchedule("*/10 * * * * ?");
return TriggerBuilder.newTrigger()
.forJob(detail)
.withIdentity("monitor-timer")
.withSchedule(cron)
.build();
}
}