This commit is contained in:
2024-01-22 11:29:28 +08:00
parent 6fdd7965e5
commit 8d68562486

View File

@@ -22,10 +22,10 @@ import org.springframework.stereotype.Service;
public class HutoolTimerExeServiceImpl implements TimerExeService {
private static final Log log = Log.get();
// @Value("${runTake.maxRetryCount}")
// private Integer maxRetryCount;
// @Value("${runTake.delayTime}")
// private Integer delayTime;
@Value("${runTake.maxRetryCount}")
private Integer maxRetryCount;
@Value("${runTake.delayTime}")
private Integer delayTime;
@Override
public void startTimer(String taskId, String cron, String className) {
@@ -63,7 +63,7 @@ public class HutoolTimerExeServiceImpl implements TimerExeService {
public void runTaskWithRetryAndDelay(TimerTaskRunner timerTaskRunner) throws InterruptedException {
int retryCount = 0; // 重试次数计数器
while (retryCount < 10) {
while (retryCount < maxRetryCount) {
try {
System.out.println("重试机制:"+(retryCount+1));
timerTaskRunner.action();
@@ -71,10 +71,10 @@ public class HutoolTimerExeServiceImpl implements TimerExeService {
} catch (Exception e) {
// 处理异常
retryCount++; // 增加重试次数
Thread.sleep(25000); // 等待一段时间
Thread.sleep(delayTime); // 等待一段时间
}
}
if (retryCount >= 10) {
if (retryCount >= maxRetryCount) {
// 达到最大重试次数,终止任务
return;
}