定时任务测试优化
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
package com.ruoyi.schedule.scheduleTask;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.scheduling.annotation.EnableAsync;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class Timer {
|
||||
|
||||
@Autowired
|
||||
Generation generation;
|
||||
|
||||
@Autowired
|
||||
Execution execution;
|
||||
|
||||
@Autowired
|
||||
StatusUpdate statusUpdate;
|
||||
|
||||
@Autowired
|
||||
TaskFinish taskFinish;
|
||||
|
||||
@Autowired
|
||||
TaskHandler taskHandler;
|
||||
|
||||
@Async
|
||||
@Scheduled(cron = "*/2 * * * * *")
|
||||
public void timerTask() {
|
||||
|
||||
try {
|
||||
execution.executeTask();
|
||||
Thread.sleep(200);
|
||||
|
||||
statusUpdate.statusUpdate();
|
||||
Thread.sleep(200);
|
||||
|
||||
taskFinish.taskFinish();
|
||||
Thread.sleep(200);
|
||||
|
||||
// generation.
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("【调度任务异常】" + e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user