parent
3aa3090fb5
commit
0993b6313d
|
@ -857,6 +857,9 @@ public class DefaultExecThread implements AtuExecThread{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
if (task.getRetryStrategy() != null && AtuExecConstant.TASK_RETRY_STRATEGY_PACKAGE.equals(task.getRetryStrategy())) {
|
||||||
|
count = task.getCurrentRetryNum();
|
||||||
|
}
|
||||||
if(null==executeResult){
|
if(null==executeResult){
|
||||||
updateExecResult(result,AtuExecConstant.TASK_FAIL,"自动重试次数:"+count+";任务执行失败,无结果返回或未执行。");
|
updateExecResult(result,AtuExecConstant.TASK_FAIL,"自动重试次数:"+count+";任务执行失败,无结果返回或未执行。");
|
||||||
}else{
|
}else{
|
||||||
|
|
|
@ -40,6 +40,11 @@ public class AutoTask {
|
||||||
*/
|
*/
|
||||||
private String retryStrategy;
|
private String retryStrategy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前重试次数
|
||||||
|
*/
|
||||||
|
private int currentRetryNum;
|
||||||
|
|
||||||
private String appId;
|
private String appId;
|
||||||
|
|
||||||
private String projectId;
|
private String projectId;
|
||||||
|
@ -227,4 +232,12 @@ public class AutoTask {
|
||||||
public void setRetryStrategy(String retryStrategy) {
|
public void setRetryStrategy(String retryStrategy) {
|
||||||
this.retryStrategy = retryStrategy;
|
this.retryStrategy = retryStrategy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCurrentRetryNum() {
|
||||||
|
return currentRetryNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentRetryNum(int currentRetryNum) {
|
||||||
|
this.currentRetryNum = currentRetryNum;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1282,6 +1282,13 @@ public class AtuPlanTaskApiServiceImpl extends AbstractExcelService<AtuPlanTask>
|
||||||
logger.error("消息队列名称或路由为空");
|
logger.error("消息队列名称或路由为空");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// 增加当前重试次数
|
||||||
|
atuTaskExecDto.setCurrentRetryNum(0);
|
||||||
|
Object o = redisTemplate.opsForHash().get(RedisConstant.PLAN_BATCH_RETRY_COUNT, atuTaskExecDto.getBatchId());
|
||||||
|
if (null != o) {
|
||||||
|
int count = Integer.parseInt(o.toString());
|
||||||
|
atuTaskExecDto.setCurrentRetryNum(atuTaskExecDto.getFailRetryNum() - count);
|
||||||
|
}
|
||||||
amqpAdmin.declareQueue(new Queue(queueName));
|
amqpAdmin.declareQueue(new Queue(queueName));
|
||||||
amqpTemplate.convertAndSend(queueName, JSONUtil.toJsonStr(atuTaskExecDto));
|
amqpTemplate.convertAndSend(queueName, JSONUtil.toJsonStr(atuTaskExecDto));
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,6 +81,12 @@ public class AtuTaskExecDto implements Serializable {
|
||||||
* 失败重试策略<br>
|
* 失败重试策略<br>
|
||||||
*/
|
*/
|
||||||
private String retryStrategy;
|
private String retryStrategy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前重试次数
|
||||||
|
*/
|
||||||
|
private int currentRetryNum;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 应用ID
|
* 应用ID
|
||||||
*/
|
*/
|
||||||
|
@ -218,4 +224,12 @@ public class AtuTaskExecDto implements Serializable {
|
||||||
public void setRetryStrategy(String retryStrategy) {
|
public void setRetryStrategy(String retryStrategy) {
|
||||||
this.retryStrategy = retryStrategy;
|
this.retryStrategy = retryStrategy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getCurrentRetryNum() {
|
||||||
|
return currentRetryNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentRetryNum(int currentRetryNum) {
|
||||||
|
this.currentRetryNum = currentRetryNum;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -293,8 +293,8 @@ public class PlanBatchTaskDataUpdateJob {
|
||||||
dto.setTaskIdList(resultIds);
|
dto.setTaskIdList(resultIds);
|
||||||
logger.info("计划-批次【{}-{}】需要重试的任务数量:{}", planInfo.getPlanName(), planBatch.getBatch(), taskIds.size());
|
logger.info("计划-批次【{}-{}】需要重试的任务数量:{}", planInfo.getPlanName(), planBatch.getBatch(), taskIds.size());
|
||||||
if (!taskIds.isEmpty()) {
|
if (!taskIds.isEmpty()) {
|
||||||
planTaskApiService.taskRetry(dto);
|
|
||||||
redisTemplate.opsForHash().put(RedisConstant.PLAN_BATCH_RETRY_COUNT, planBatch.getId(), String.valueOf(--count));
|
redisTemplate.opsForHash().put(RedisConstant.PLAN_BATCH_RETRY_COUNT, planBatch.getId(), String.valueOf(--count));
|
||||||
|
planTaskApiService.taskRetry(dto);
|
||||||
} else {
|
} else {
|
||||||
redisTemplate.opsForHash().delete(RedisConstant.PLAN_BATCH_RETRY_COUNT, planBatch.getId()); // 没有失败的任务,清除redis信息,不需要重试
|
redisTemplate.opsForHash().delete(RedisConstant.PLAN_BATCH_RETRY_COUNT, planBatch.getId()); // 没有失败的任务,清除redis信息,不需要重试
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue