代码提交
This commit is contained in:
@@ -26,6 +26,7 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -165,7 +166,7 @@ public class TimersServiceImpl extends ServiceImpl<TimersMapper, Timers> impleme
|
||||
int retryCount = 0;
|
||||
while (retryCount < maxRetryCount) {
|
||||
try {
|
||||
System.out.println("重试机制:"+(retryCount+1));
|
||||
System.out.println(LocalDateTime.now()+"手动重试机制:"+(retryCount+1));
|
||||
timerTaskRunner.action(date);
|
||||
System.out.println("成功重试机制:"+(retryCount+1));
|
||||
return; // 任务执行成功,跳出循环
|
||||
|
||||
@@ -14,6 +14,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* hutool方式的定时任务执行
|
||||
*
|
||||
@@ -67,10 +69,11 @@ public class HutoolTimerExeServiceImpl implements TimerExeService {
|
||||
int retryCount = 0;
|
||||
while (retryCount < maxRetryCount) {
|
||||
try {
|
||||
System.out.println("重试机制:"+(retryCount+1));
|
||||
System.out.println(LocalDateTime.now()+"自动重试机制:"+(retryCount+1));
|
||||
timerTaskRunner.action(null);
|
||||
return; // 任务执行成功,跳出循环
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// 处理异常
|
||||
// 增加重试次数
|
||||
retryCount++;
|
||||
|
||||
Reference in New Issue
Block a user