完成运行时状态上报功能
This commit is contained in:
parent
81622001ce
commit
4bb27f6d5c
@ -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();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user