小Hub領讀:常見的分布式定時任務框架:elastic-job、xxl-job、quartz ,你都熟悉嗎,今天先來學一下Quartz吧!
作者:Sam Sho https://blog.csdn.net/u012228718/article/details/90041675
見名知意,該篇番外主要是要解決如下幾個問題: 1、使用 SpringBoot2.x 版本集成 Quartz 2、Quartz 的任務動態(tài)實現(xiàn): 3、Quartz 實現(xiàn)分布式調度,使用其本身提供的基于數(shù)據(jù)庫的實現(xiàn) SpringBoot2 集成 Quartz1、SpringBoot 不同的版本對于 Quartz 的集成有一定的差別,本文使用 2.1.2.RELEASE 版本。其實通過分析 SpringBoot 對于 Quartz 的自動化配置源碼,也有助于我們理解 Quartz 的使用 2、SpringBoot-2.1.2.RELEASE 版本已經(jīng)集成了對于 Quartz 的自動化配置,其源碼路徑為 org.springframework.boot.autoconfigure.quartz 集成簡單實現(xiàn)Pom 依賴# Web工程
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
# quartz
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-quartz</artifactId>
</dependency>
# 數(shù)據(jù)庫JDBC
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
# 使用MySql
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
編碼功能實現(xiàn)1、由于 Springboot2 的自動化配置,不需要做任何配置,直接寫 JobDetail、Trigger、Job 即可實現(xiàn) # Job 實現(xiàn)
@DisallowConcurrentExecution
public class DemoJob extends QuartzJobBean {
@Override
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
System.out.println('~~ DemoJob 啟動運行匯總~~');
}
}
# JobDetail、Trigger Bean配置
@Configuration
public class QuartzJobConfig {
@Bean
public JobDetailFactoryBean jobDetailFactoryBean() {
JobDetailFactoryBean jobDetail = new JobDetailFactoryBean();
jobDetail.setName('DemoJob');
jobDetail.setGroup('DemoJob_Group');
jobDetail.setJobClass(DemoJob.class);
jobDetail.setDurability(true);
return jobDetail;
}
@Bean
public CronTriggerFactoryBean cronTriggerFactoryBean() {
CronTriggerFactoryBean trigger = new CronTriggerFactoryBean();
trigger.setJobDetail(jobDetailFactoryBean().getObject());
trigger.setCronExpression('*/10 * * * * ?');
trigger.setName('DemoJob');
trigger.setMisfireInstruction(0);
return trigger;
}
}
2、這樣就實現(xiàn)了 SpringBoot2.x 版本集成 Quartz 功能,在進行下一步之前,我們先對自動化配置的源碼簡單分析一下。 自動配置實現(xiàn)分析SpringBoot 關于 Quartz 的自動配置的類一共有 6 個,分別為: 1、 JobStoreType:是一個枚舉類,定義了 jobsStore 的類型,基于內(nèi)存和數(shù)據(jù)庫 2、 QuartzAutoConfiguration:自動配置類,配置了 Quartz 的主要組件,如 SchedulerFactoryBean 3、 QuartzDataSource:是一個注解類。如果需要注入 Quartz 配置的數(shù)據(jù)庫操作類,需要使用此注解標注。參考 QuartzAutoConfiguration中的用法 4、 QuartzDataSourceInitializer:該類主要用于數(shù)據(jù)源初始化后的一些操作,根據(jù)不同平臺類型的數(shù)據(jù)庫進行選擇不同的數(shù)據(jù)庫腳本 5、 QuartzProperties:該類對應了在 application.yml配置文件以 spring.quartz開頭的相關配置 6、 SchedulerFactoryBeanCustomizer:在自動配置的基礎上自定義配置需要實現(xiàn)的此接口。 自動化配置分析 QuartzAutoConfiguration1、初始化注入任務以及配置:構造函數(shù)實現(xiàn) 注入了屬性配置文件類: QuartzProperties 注入了自定義擴展配置: SchedulerFactoryBeanCustomizer 注入了 Quartz 的任務組件: JobDetail、 Trigger、 Calendar。所以我們只需要進行 JobDetail、Trigger Bean 配置,會自動注入進 QuartzAutoConfiguration類中,這邊是通過 ObjectProvider的使用實現(xiàn)的。
public QuartzAutoConfiguration(QuartzProperties properties,
ObjectProvider<SchedulerFactoryBeanCustomizer> customizers,
ObjectProvider<JobDetail[]> jobDetails,
ObjectProvider<Map<String, Calendar>> calendars,
ObjectProvider<Trigger[]> triggers, ApplicationContext applicationContext) {
this.properties = properties;
this.customizers = customizers;
this.jobDetails = jobDetails.getIfAvailable();
this.calendars = calendars.getIfAvailable();
this.triggers = triggers.getIfAvailable();
this.applicationContext = applicationContext;
}
2、配置 SchedulerFactoryBean 的詳細信息。這個類是一個 FactoryBean。 配置 JobFactory,內(nèi)部設置了 applicationContext與 spring 容器結合 配置各種屬性,是通過 QuartzProperties類實現(xiàn) 配置注入進來的 JobDetail、 Trigger、 Calendar 配置自定配置,是通過 SchedulerFactoryBeanCustomizer實現(xiàn)。這邊包括自定義,也包括基于數(shù)據(jù)庫實現(xiàn)的 JobStore配置。
@Bean
@ConditionalOnMissingBean
public SchedulerFactoryBean quartzScheduler() {
# 配置 `JobFactory`
SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean();
SpringBeanJobFactory jobFactory = new SpringBeanJobFactory();
jobFactory.setApplicationContext(this.applicationContext);
schedulerFactoryBean.setJobFactory(jobFactory);
# 開始配置各種屬性
if (this.properties.getSchedulerName() != null) {
schedulerFactoryBean.setSchedulerName(this.properties.getSchedulerName());
}
schedulerFactoryBean.setAutoStartup(this.properties.isAutoStartup());
schedulerFactoryBean
.setStartupDelay((int) this.properties.getStartupDelay().getSeconds());
schedulerFactoryBean.setWaitForJobsToCompleteOnShutdown(
this.properties.isWaitForJobsToCompleteOnShutdown());
schedulerFactoryBean
.setOverwriteExistingJobs(this.properties.isOverwriteExistingJobs());
if (!this.properties.getProperties().isEmpty()) {
schedulerFactoryBean
.setQuartzProperties(asProperties(this.properties.getProperties()));
}
# 配置 jobDetails、triggers等
if (this.jobDetails != null && this.jobDetails.length > 0) {
schedulerFactoryBean.setJobDetails(this.jobDetails);
}
if (this.calendars != null && !this.calendars.isEmpty()) {
schedulerFactoryBean.setCalendars(this.calendars);
}
if (this.triggers != null && this.triggers.length > 0) {
schedulerFactoryBean.setTriggers(this.triggers);
}
# 自定義配置
customize(schedulerFactoryBean);
return schedulerFactoryBean;
}
3、基于數(shù)據(jù)庫實現(xiàn)的 JobStore 配置,內(nèi)部類 JdbcStoreTypeConfiguration @ConditionalOnSingleCandidate(DataSource.class) 指定 pring 容器中有且只有一個指明的 DataSourceBean 時生效
通過 dataSourceCustomizer方法實現(xiàn) schedulerFactoryBean的數(shù)據(jù)庫相關配置,該方法返回一個 SchedulerFactoryBeanCustomizer。 配置 QuartzDataSourceInitializer 數(shù)據(jù)庫初始化 Bean
4、通過后置工廠處理器 DataSourceInitializerSchedulerDependencyPostProcessor 實現(xiàn)對于 QuartzDataSourceInitializer這個 Bean 的依賴關系(dependsOn) @Bean
@Order(0)
public SchedulerFactoryBeanCustomizer dataSourceCustomizer(
QuartzProperties properties, DataSource dataSource,
@QuartzDataSource ObjectProvider<DataSource> quartzDataSource,
ObjectProvider<PlatformTransactionManager> transactionManager) {
return (schedulerFactoryBean) -> {
# 判斷是否為 JobStore
if (properties.getJobStoreType() == JobStoreType.JDBC) {
# 獲取 DataSource
DataSource dataSourceToUse = getDataSource(dataSource, quartzDataSource);
# 配置 DataSource 和 TransactionManager管理
schedulerFactoryBean.setDataSource(dataSourceToUse);
PlatformTransactionManager txManager = transactionManager.getIfUnique();
if (txManager != null) {
schedulerFactoryBean.setTransactionManager(txManager);
}
}
};
}
支持功能配置 QuartzProperties1、 @ConfigurationProperties('spring.quartz') 以 spring.quartz開頭的配置 2、SpringBoot 已經(jīng)做了相應的默認值處理,即使不做任何配置,也是沒有問題的。 3、比較簡單,直接貼碼。屬性的具體含義,任務調度框架(3)Quartz 簡單使用 spring:
quartz:
scheduler-name: springboot-quartz-jdbc-dynamic
auto-startup: false
startup-delay: 5s
overwrite-existing-jobs: false
wait-for-jobs-to-complete-on-shutdown: true
job-store-type: memory
# jdbc:
# initialize-schema: embedded
# schema: classpath:org/quartz/impl/jdbcjobstore/tables_@@platform@@.sql
# comment-prefix: --
properties: {
org.quartz.scheduler.instanceName: springboot-quartz-jdbc-dynamic,
org.quartz.scheduler.instanceId: AUTO,
org.quartz.threadPool.class: org.springframework.scheduling.quartz.SimpleThreadPoolTaskExecutor,
org.quartz.threadPool.threadCount: 25,
org.quartz.threadPool.threadPriority: 5,
org.quartz.jobStore.misfireThreshold: 60000,
# org.quartz.jobStore.tablePrefix: QRTZ_,
# org.quartz.jobStore.isClustered: true,
# org.quartz.jobStore.clusterCheckinInterval: 20000,
# org.quartz.jobStore.maxMisfiresToHandleAtATime: 1,
# org.quartz.jobStore.txIsolationLevelSerializable: false
}
小結1、至此,我們完成了 SpringBoot 與 Quartz 的集成,并且簡單運行了我們的調度任務 2、簡單分析了 SpringBoot 對于 Quartz 的自動配置,由于各個版本的差別,這邊使用的是 SpringBoot-2.1.2.RELEASE Quartz 實現(xiàn)分布式調度回顧分析任務調度框架(4)Quartz 分布式實現(xiàn) 已經(jīng)對 Quartz 自身的分布式實現(xiàn)做了簡單的介紹,這邊主要基于 SpringBoot 怎么做。 配置簡單實現(xiàn)1、上述完成的 SpringBoot 與 Quartz 的集成,可以看到有幾個先關的配置: job-store-type 可以選擇 JDBC完成分布式 JdbcJobStore切換
jdbc.XXX 主要是對于初始化 SQL 的配置。樹妖是對于 quartz 提供的 11 張表的初始化 sql
對于 JdbcJobStore 的一些特殊配置,如表前綴、集群指定、數(shù)據(jù)庫檢查等,基于 RamJobStore時,這些是不允許配置的。
spring:
quartz:
job-store-type: memory
jdbc:
initialize-schema: embedded
schema: classpath:org/quartz/impl/jdbcjobstore/tables_@@platform@@.sql
comment-prefix: --
properties: {
org.quartz.jobStore.misfireThreshold: 60000,
org.quartz.jobStore.tablePrefix: QRTZ_,
org.quartz.jobStore.isClustered: true,
org.quartz.jobStore.clusterCheckinInterval: 20000,
org.quartz.jobStore.maxMisfiresToHandleAtATime: 1,
org.quartz.jobStore.txIsolationLevelSerializable: false
}
2、以上就配置好了 Quartz 實現(xiàn)分布式調度,就是這么簡單 3、【注意】在嘗試的時候, jdbc.xxx配置沒有生效,個人是自己手動初始化的表。 Quartz 的任務動態(tài)實現(xiàn)1、以上我們簡單完成了 SpringBoot 集成與基于 JDBC 的分布式,但是我們的任務還是基于 Bean 配置的: 2、所以,所謂的動態(tài)任務主要是三個問題: 任務數(shù)據(jù)使用數(shù)據(jù)庫保存,包括任務的基本信息與 trigger 信息 調度任務可以通過頁面進行新增、修改、刪除、啟動、暫停、重啟等操作 任務之間實現(xiàn)簡單的依賴,如 A 任務依賴于 B 任務,那么 A 任務必須等到 B 任務執(zhí)行完成才會自動執(zhí)行
數(shù)據(jù)使用數(shù)據(jù)庫保存1、簡單,把任務調度分為兩個模塊: 2、具體的實體如下,數(shù)據(jù)庫相關表結構略 public class BatchTask extends AbstractDataEntity {
/**
* 任務編碼:唯一
*/
private String code;
/**
* 任務名稱
*/
private String name;
/**
* 任務描述
*/
private String description;
/**
* 前置任務
*/
private List<BatchTask> previous;
}
public class BatchSchedule extends AbstractDataEntity {
/**
* 計劃編碼
*/
private String code;
/**
* 計劃名稱
*/
private String name;
/**
* 計劃狀態(tài): 整個生命周期狀態(tài)
*/
private Integer status;
/**
* 執(zhí)行表達式類型
*/
private Integer cronType;
/**
* 執(zhí)行表達式
*/
private String cronExpression;
/**
* 描述
*/
private String description;
/**
* 處理業(yè)務類
*/
private String interfaceName;
/**
* 任務編碼(任務組的概念)
*/
private String taskCode;
/**
* 開始時間(最近)
*/
private Date startDate;
/**
* 結束時間(最近)
*/
private Date endDate;
/**
* 前置計劃列表
*/
private List<BatchSchedule> dependencies;
/**
* 參數(shù)列表
*/
private List<BatchScheduleParam> params;
}
public class BatchScheduleParam {
/**
* 任務計劃ID
*/
private String scheduleId;
/**
* 任務計劃code
*/
private String scheduleCode;
/**
* 參數(shù)名
*/
private String paramName;
/**
* 參數(shù)值
*/
private String paramValue;
}
3、有了這些實體,無非就是根據(jù)實體對基本任務與任務計劃做 CRUD,這個比較簡單,不贅述。 

任務計劃的動態(tài)管理手動配置實現(xiàn)的原理1、手動配置是需要編碼實現(xiàn) JobDetailFactoryBean、 CronTriggerFactoryBean,然后通過 SpringBoot 的自動化配置,設置到
schedulerFactoryBean對象的對應屬性中。 schedulerFactoryBean.setJobDetails(this.jobDetails);
schedulerFactoryBean.setTriggers(this.triggers);
2、 SchedulerFactoryBean源碼中,通過 afterPropertiesSet()方法中方法,注冊到 Scheduler對象中 // Initialize the Scheduler instance...
this.scheduler = prepareScheduler(prepareSchedulerFactory());
try {
registerListeners();
registerJobsAndTriggers(); # 注冊JobsAndTriggers
}
protected void registerJobsAndTriggers() throws SchedulerException {
// Register JobDetails.
if (this.jobDetails != null) {
for (JobDetail jobDetail : this.jobDetails) {
addJobToScheduler(jobDetail);
}
}
// Register Triggers.
if (this.triggers != null) {
for (Trigger trigger : this.triggers) {
addTriggerToScheduler(trigger);
}
}
}
private boolean addJobToScheduler(JobDetail jobDetail) throws SchedulerException {
if (this.overwriteExistingJobs || getScheduler().getJobDetail(jobDetail.getKey()) == null) {
# 最終是通過Scheduler.addJob(jobDetail, true); 添加
getScheduler().addJob(jobDetail, true);
return true;
}
else {
return false;
}
}
private boolean addTriggerToScheduler(Trigger trigger) throws SchedulerException {
# 最終是通過Scheduler.scheduleJob(jobDetail, trigger); 添加(只是一部分功能)
getScheduler().scheduleJob(jobDetail, trigger);
}
動態(tài)管理:創(chuàng)建計劃任務引擎類1、 Scheduler 在 SpringBoot 中已經(jīng)通過 SchedulerFactoryBean自動配置好了,直接注入即可使用。 2、具體可以 參考源碼 public class QuartzScheduleEngine {
@Autowired
private Scheduler scheduler;
/**
* 新增計劃任務: 主要是添加 jobDetail 和 trigger
*
* @param batchSchedule
*/
public Date addJob(BatchSchedule batchSchedule) throws Exception {
String cronExpression = batchSchedule.getCronExpression();
String name = batchSchedule.getCode();
String group = batchSchedule.getTaskCode();
String interfaceName = batchSchedule.getInterfaceName();
// 校驗數(shù)據(jù)
this.checkNotNull(batchSchedule);
// 添加 1-JobDetail
// 校驗 JobDetail 是否存在
JobKey jobKey = JobKey.jobKey(name, group);
if (scheduler.checkExists(jobKey)) {
if (Strings.isNullOrEmpty(cronExpression)) {
// 已經(jīng)存在并且執(zhí)行一次,立即執(zhí)行
scheduler.triggerJob(jobKey);
} else {
throw new Exception('任務計劃 JobKey 已經(jīng)在執(zhí)行隊列中,不需要重復啟動');
}
} else {
// 構建 JobDetail
Class<? extends Job> jobClazz = (Class<? extends Job>) Class.forName(interfaceName);
JobDetail jobDetail = JobBuilder.newJob(jobClazz).withIdentity(jobKey).build();
jobDetail.getJobDataMap().put(BatchSchedule.SCHEDULE_KEY, batchSchedule.toString());
// 添加 2-Trigger
// 校驗 Trigger 是否存在
TriggerKey triggerKey = TriggerKey.triggerKey(name, group);
Trigger trigger = scheduler.getTrigger(triggerKey);
if (Objects.nonNull(trigger)) {
throw new Exception('任務計劃 Trigger 已經(jīng)在執(zhí)行隊列中,不需要重復啟動');
}
// 構建 Trigger
trigger = getTrigger(cronExpression, triggerKey);
return scheduler.scheduleJob(jobDetail, trigger);
}
return new Date();
}
/**
* 修改
*
* @param batchSchedule
*/
public void updateCronExpression(BatchSchedule batchSchedule) throws Exception {
updateJobCronExpression(batchSchedule);
}
/**
* 更新Job的執(zhí)行表達式
*
* @param batchSchedule
* @throws SchedulerException
*/
public Date updateJobCronExpression(BatchSchedule batchSchedule) throws SchedulerException {
checkNotNull(batchSchedule);
String name = batchSchedule.getCode();
String group = batchSchedule.getTaskCode();
TriggerKey triggerKey = TriggerKey.triggerKey(name, group);
// 在隊列中才需要修改
if (scheduler.checkExists(triggerKey)) {
// 構建 Trigger
String cronExpression = batchSchedule.getCronExpression();
Trigger trigger = this.getTrigger(cronExpression, triggerKey);
return scheduler.rescheduleJob(triggerKey, trigger);
}
return null;
}
/**
* 構建 Trigger
*
* @param cronExpression
* @param triggerKey
* @return
*/
private Trigger getTrigger(String cronExpression, TriggerKey triggerKey) {
Trigger trigger;
if (Strings.isNullOrEmpty(cronExpression.trim())) {
trigger = TriggerBuilder.newTrigger().withIdentity(triggerKey).build();
} else {
cronExpression = cronExpression.replaceAll('#', ' ');
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(cronExpression);
trigger = TriggerBuilder.newTrigger().withIdentity(triggerKey).withSchedule(cronScheduleBuilder).build();
}
return trigger;
}
/**
* 暫停計劃任務
*
* @param batchSchedule
*/
public void pauseJob(BatchSchedule batchSchedule) throws Exception {
checkNotNull(batchSchedule);
JobKey jobKey = JobKey.jobKey(batchSchedule.getCode(), batchSchedule.getTaskCode());
if (!scheduler.checkExists(jobKey)) {
throw new Exception('任務計劃不在執(zhí)行隊列中,不能暫停');
}
scheduler.pauseJob(jobKey);
}
/**
* 從暫停中恢復
*
* @param batchSchedule
*/
public void resumeJob(BatchSchedule batchSchedule) throws Exception {
checkNotNull(batchSchedule);
JobKey jobKey = JobKey.jobKey(batchSchedule.getCode(), batchSchedule.getTaskCode());
if (!scheduler.checkExists(jobKey)) {
throw new Exception('任務計劃不在執(zhí)行隊列中,不能恢復');
}
scheduler.resumeJob(jobKey);
}
/**
* 刪除計劃任務
*
* @param batchSchedule
*/
public boolean deleteJob(BatchSchedule batchSchedule) throws SchedulerException {
boolean flag = true;
checkNotNull(batchSchedule);
JobKey jobKey = JobKey.jobKey(batchSchedule.getCode(), batchSchedule.getTaskCode());
if (scheduler.checkExists(jobKey)) {
flag = scheduler.deleteJob(jobKey);
}
return flag;
}
/**
* 添加任務監(jiān)聽
*
* @param jobListener
* @param matcher
* @throws SchedulerException
*/
public void addJobListener(JobListener jobListener, Matcher<JobKey> matcher) throws SchedulerException {
scheduler.getListenerManager().addJobListener(jobListener, matcher);
}
/**
* 執(zhí)行一次(可用于測試)
*
* @param batchSchedule
*/
public void runJobOnce(BatchSchedule batchSchedule) throws SchedulerException {
checkNotNull(batchSchedule);
JobKey jobKey = JobKey.jobKey(batchSchedule.getCode(), batchSchedule.getTaskCode());
scheduler.triggerJob(jobKey);
}
private void checkNotNull(BatchSchedule batchSchedule) {
Preconditions.checkNotNull(batchSchedule, '計劃為空');
Preconditions.checkState(!StringUtils.isEmpty(batchSchedule.getCode()), '計劃編號為空');
Preconditions.checkState(!StringUtils.isEmpty(batchSchedule.getTaskCode()), '計劃所屬任務為空');
Preconditions.checkState(!StringUtils.isEmpty(batchSchedule.getInterfaceName()), '任務執(zhí)行業(yè)務類為空');
}
public SchedulerMetaData getMetaData() throws SchedulerException {
SchedulerMetaData metaData = scheduler.getMetaData();
return metaData;
}
}
任務狀態(tài)與計劃依賴1、使用 JobListener實現(xiàn),需要自定義配置的支持 public class CustomGlobalJobListener extends JobListenerSupport {
@Override
public String getName() {
return this.getClass().getName();
}
/**
* Scheduler 在 JobDetail 將要被執(zhí)行時調用這個方法。
*
* @param context
*/
@Override
public void jobToBeExecuted(JobExecutionContext context) {
getLog().debug('計劃 {} : ~~~ 【RUNNING】 更新正在運行中狀態(tài) ~~~ ');
}
/**
* Scheduler 在 JobDetail 即將被執(zhí)行,但又被 TriggerListener 否決了時調用這個方法
*
* @param context
*/
@Override
public void jobExecutionVetoed(JobExecutionContext context) {
}
/**
* Scheduler 在 JobDetail 被執(zhí)行之后調用這個方法
*
* @param context
* @param jobException
*/
@Override
public void jobWasExecuted(JobExecutionContext context, JobExecutionException jobException) {
getLog().debug('計劃 {} : ~~~ 【COMPLETE | ERROR】 更新已經(jīng)結束狀態(tài) ~~~ ');
// 喚醒子任務
batchScheduleService.notifyChildren(scheduleJob);
}
}
2、自定義實現(xiàn),可以實現(xiàn) SchedulerFactoryBeanCustomizer接口 @Configuration
public class SchedulerFactoryBeanCustomizerConfig implements SchedulerFactoryBeanCustomizer {
@Bean
public CustomGlobalJobListener globalJobListener() {
return new CustomGlobalJobListener();
}
@Override
public void customize(SchedulerFactoryBean schedulerFactoryBean) {
schedulerFactoryBean.setGlobalJobListeners(globalJobListener());
}
}
3、計劃依賴: 小結至此,Quartz 的任務動態(tài)實現(xiàn)已經(jīng)完成,主要可以分為三個部分:
1、任務與計劃定義,使用數(shù)據(jù)庫保存 2、動態(tài)計劃的管理,使用 Quartz 本身的 API 實現(xiàn) 3、任務計劃狀態(tài)監(jiān)控,使用 JobListener監(jiān)聽器實現(xiàn) 4、計劃依賴,使用 JobListener監(jiān)聽器實現(xiàn)。 參考1、lotso-web:使用 SpringBoot2.X 實現(xiàn) Quartz 動態(tài)任務的分布式調度 2、源碼地址 LearningJobSchedule
(完)
|