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