微调
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user