feat: 1.1.0
1. 新增更新执行器能力 2. 优化核心字段描述 3. Assert优化使用hutool的Assert 4. 优化类名定义
This commit is contained in:
parent
b4e6922378
commit
ce4163ceb0
@ -1,10 +1,33 @@
|
|||||||
package com.aizuda.easy.retry.client.core;
|
package com.aizuda.easy.retry.client.core;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 业务id生成器
|
||||||
|
* 同一个组的同一个场景下只会存在一个相同的bizId重试任务, 若存在相同的则上报服务后会被幂等处理
|
||||||
|
* 比如:
|
||||||
|
* 组: AGroup
|
||||||
|
* 场景: BScene
|
||||||
|
* 时刻1: 上报一个异常 bizId: A1 状态为重试中
|
||||||
|
* 时刻2: 上报一个异常 bizId: A2 状态为重试中,可以上报成功,此时存在两个重试任务
|
||||||
|
* 时刻3: 上报一个异常 bizId: A1 不会新增一个重试任务,会被幂等处理
|
||||||
|
* 时刻4: bizId: A1 重试完成, 状态为已完成
|
||||||
|
* 时刻5: 上报一个异常 bizId: A1 状态为重试中, 新增一条重试任务
|
||||||
|
*
|
||||||
* @author: www.byteblogs.com
|
* @author: www.byteblogs.com
|
||||||
* @date : 2022-03-08 09:42
|
* @date : 2022-03-08 09:42
|
||||||
*/
|
*/
|
||||||
public interface BizIdGenerate {
|
public interface BizIdGenerate {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 参数列表为Object一维数组, 下面说明每一个下标代表的数据含义
|
||||||
|
* 0: 场景名称: scene(String)
|
||||||
|
* 1: 执行器名称: targetClassName(String)
|
||||||
|
* 2: 参数列表: args(Object[])
|
||||||
|
* 3: 执行的方法名称: methodName(String)
|
||||||
|
* scene, targetClassName, args, executorMethod.getName()
|
||||||
|
*
|
||||||
|
* @param t 参数列表
|
||||||
|
* @return bizId
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
String idGenerate(Object... t) throws Exception;
|
String idGenerate(Object... t) throws Exception;
|
||||||
}
|
}
|
||||||
|
@ -49,9 +49,20 @@ public @interface Retryable {
|
|||||||
Class<? extends RetryMethod> retryMethod() default RetryAnnotationMethod.class;
|
Class<? extends RetryMethod> retryMethod() default RetryAnnotationMethod.class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义业务id,默认为hash(param),传入成员列表,全部拼接取hash
|
* 业务id生成器
|
||||||
|
* 同一个组的同一个场景下只会存在一个相同的bizId重试任务, 若存在相同的则上报服务后会被幂等处理
|
||||||
|
* 比如:
|
||||||
|
* 组: AGroup
|
||||||
|
* 场景: BScene
|
||||||
|
* 时刻1: 上报一个异常 bizId: A1 状态为重试中
|
||||||
|
* 时刻2: 上报一个异常 bizId: A2 状态为重试中,可以上报成功,此时存在两个重试任务
|
||||||
|
* 时刻3: 上报一个异常 bizId: A1 不会新增一个重试任务,会被幂等处理
|
||||||
|
* 时刻4: bizId: A1 重试完成, 状态为已完成
|
||||||
|
* 时刻5: 上报一个异常 bizId: A1 状态为重试中, 新增一条重试任务
|
||||||
|
**
|
||||||
|
* 默认的bizId生成器{@link SimpleBizIdGenerate} 对所有参数进行MD5
|
||||||
*
|
*
|
||||||
* @return
|
* @return bizId
|
||||||
*/
|
*/
|
||||||
Class<? extends BizIdGenerate> bizId() default SimpleBizIdGenerate.class;
|
Class<? extends BizIdGenerate> bizId() default SimpleBizIdGenerate.class;
|
||||||
|
|
||||||
@ -63,7 +74,9 @@ public @interface Retryable {
|
|||||||
Class<? extends RetryCompleteCallback> retryCompleteCallback() default SimpleRetryCompleteCallback.class;
|
Class<? extends RetryCompleteCallback> retryCompleteCallback() default SimpleRetryCompleteCallback.class;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* bizNo spel表达式
|
* 用于标识具有业务特点的值, 比如订单号、物流编号等,可以根据具体的业务场景生成,生成规则采用通用成熟的Spel表达式进行解析
|
||||||
|
*
|
||||||
|
* see: https://docs.spring.io/spring-framework/docs/5.0.0.M5/spring-framework-reference/html/expressions.html
|
||||||
*/
|
*/
|
||||||
String bizNo() default "";
|
String bizNo() default "";
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import com.aizuda.easy.retry.common.core.enums.RetryResultStatusEnum;
|
|||||||
import com.aizuda.easy.retry.common.core.enums.RetryStatusEnum;
|
import com.aizuda.easy.retry.common.core.enums.RetryStatusEnum;
|
||||||
import com.aizuda.easy.retry.common.core.log.LogUtils;
|
import com.aizuda.easy.retry.common.core.log.LogUtils;
|
||||||
import com.aizuda.easy.retry.common.core.model.Result;
|
import com.aizuda.easy.retry.common.core.model.Result;
|
||||||
|
import com.aizuda.easy.retry.common.core.util.Assert;
|
||||||
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
||||||
import com.aizuda.easy.retry.server.model.dto.ConfigDTO;
|
import com.aizuda.easy.retry.server.model.dto.ConfigDTO;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
@ -37,6 +38,8 @@ import java.lang.reflect.Method;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 服务端调调用客户端进行重试流量下发、配置变更通知等操作
|
||||||
|
*
|
||||||
* @author: www.byteblogs.com
|
* @author: www.byteblogs.com
|
||||||
* @date : 2022-03-09 16:33
|
* @date : 2022-03-09 16:33
|
||||||
*/
|
*/
|
||||||
@ -137,19 +140,21 @@ public class RetryEndPoint {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 手动新增重试数据,模拟生成bizid
|
* 手动新增重试数据,模拟生成bizId
|
||||||
*
|
*
|
||||||
* @param generateRetryBizIdDTO 生成bizId模型
|
* @param generateRetryBizIdDTO 生成bizId模型
|
||||||
* @return bizId
|
* @return bizId
|
||||||
*/
|
*/
|
||||||
@PostMapping("/generate/biz-id")
|
@PostMapping("/generate/biz-id")
|
||||||
public String bizIdGenerate(@RequestBody @Validated GenerateRetryBizIdDTO generateRetryBizIdDTO) {
|
public Result<String> bizIdGenerate(@RequestBody @Validated GenerateRetryBizIdDTO generateRetryBizIdDTO) {
|
||||||
|
|
||||||
String scene = generateRetryBizIdDTO.getScene();
|
String scene = generateRetryBizIdDTO.getScene();
|
||||||
String executorName = generateRetryBizIdDTO.getExecutorName();
|
String executorName = generateRetryBizIdDTO.getExecutorName();
|
||||||
String argsStr = generateRetryBizIdDTO.getArgsStr();
|
String argsStr = generateRetryBizIdDTO.getArgsStr();
|
||||||
|
|
||||||
RetryerInfo retryerInfo = RetryerInfoCache.get(scene, executorName);
|
RetryerInfo retryerInfo = RetryerInfoCache.get(scene, executorName);
|
||||||
|
Assert.notNull(retryerInfo, ()-> new EasyRetryClientException("重试信息不存在 scene:[{}] executorName:[{}]", scene, executorName));
|
||||||
|
|
||||||
Method executorMethod = retryerInfo.getExecutorMethod();
|
Method executorMethod = retryerInfo.getExecutorMethod();
|
||||||
|
|
||||||
RetryArgSerializer retryArgSerializer = new JacksonSerializer();
|
RetryArgSerializer retryArgSerializer = new JacksonSerializer();
|
||||||
@ -173,6 +178,6 @@ public class RetryEndPoint {
|
|||||||
throw new EasyRetryClientException("bizId生成异常:{},{}", scene, argsStr);
|
throw new EasyRetryClientException("bizId生成异常:{},{}", scene, argsStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return bizId;
|
return new Result<>(bizId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ import com.aizuda.easy.retry.client.core.BizIdGenerate;
|
|||||||
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
import com.aizuda.easy.retry.common.core.util.JsonUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 默认的bizId 生成器
|
||||||
|
*
|
||||||
* @author: www.byteblogs.com
|
* @author: www.byteblogs.com
|
||||||
* @date : 2022-03-08 09:42
|
* @date : 2022-03-08 09:42
|
||||||
*/
|
*/
|
||||||
|
@ -14,7 +14,7 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
|
|||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ControllerAdvice(basePackages = {"com.aizuda.easy.retry.client.core", "com.aizuda.easy.retry.server"})
|
@ControllerAdvice(basePackages = {"com.aizuda.easy.retry.server"})
|
||||||
public class GlobalRestfulResponseBodyAdvice implements ResponseBodyAdvice<Object> {
|
public class GlobalRestfulResponseBodyAdvice implements ResponseBodyAdvice<Object> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -6,9 +6,4 @@ package com.aizuda.easy.retry.common.core.util;
|
|||||||
*/
|
*/
|
||||||
public class Assert extends cn.hutool.core.lang.Assert {
|
public class Assert extends cn.hutool.core.lang.Assert {
|
||||||
|
|
||||||
public static <T extends RuntimeException> void isTrue(boolean expression, T e) {
|
|
||||||
if (!expression) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ public class MybatisRetryTaskAccess extends AbstractRetryTaskAccess {
|
|||||||
|
|
||||||
setPartition(retryTask.getGroupName());
|
setPartition(retryTask.getGroupName());
|
||||||
int i = retryTaskMapper.insert(retryTask);
|
int i = retryTaskMapper.insert(retryTask);
|
||||||
Assert.isTrue(1 == i, new EasyRetryServerException("同步重试数据失败", JsonUtil.toJsonString(retryTask)));
|
Assert.isTrue(1 == i, () -> new EasyRetryServerException("同步重试数据失败", JsonUtil.toJsonString(retryTask)));
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ public class RetryTaskAccessProcessor implements RetryTaskAccess<RetryTask> {
|
|||||||
@Override
|
@Override
|
||||||
public int updateRetryTask(RetryTask retryTask) {
|
public int updateRetryTask(RetryTask retryTask) {
|
||||||
Assert.isTrue(1 == retryTaskAccesses.updateRetryTask(retryTask),
|
Assert.isTrue(1 == retryTaskAccesses.updateRetryTask(retryTask),
|
||||||
new EasyRetryServerException("更新重试任务失败"));
|
() -> new EasyRetryServerException("更新重试任务失败"));
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package com.aizuda.easy.retry.server.service;
|
package com.aizuda.easy.retry.server.service;
|
||||||
|
|
||||||
import com.aizuda.easy.retry.client.model.GenerateRetryBizIdDTO;
|
|
||||||
import com.aizuda.easy.retry.server.web.model.base.PageResult;
|
import com.aizuda.easy.retry.server.web.model.base.PageResult;
|
||||||
|
import com.aizuda.easy.retry.server.web.model.request.GenerateRetryBizIdVO;
|
||||||
import com.aizuda.easy.retry.server.web.model.request.RetryTaskQueryVO;
|
import com.aizuda.easy.retry.server.web.model.request.RetryTaskQueryVO;
|
||||||
import com.aizuda.easy.retry.server.web.model.request.RetryTaskRequestVO;
|
import com.aizuda.easy.retry.server.web.model.request.RetryTaskUpdateStatusRequestVO;
|
||||||
import com.aizuda.easy.retry.server.web.model.request.RetryTaskSaveRequestVO;
|
import com.aizuda.easy.retry.server.web.model.request.RetryTaskSaveRequestVO;
|
||||||
|
import com.aizuda.easy.retry.server.web.model.request.RetryTaskUpdateExecutorNameRequestVO;
|
||||||
import com.aizuda.easy.retry.server.web.model.response.RetryTaskResponseVO;
|
import com.aizuda.easy.retry.server.web.model.response.RetryTaskResponseVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -18,9 +19,22 @@ public interface RetryTaskService {
|
|||||||
|
|
||||||
PageResult<List<RetryTaskResponseVO>> getRetryTaskPage(RetryTaskQueryVO queryVO);
|
PageResult<List<RetryTaskResponseVO>> getRetryTaskPage(RetryTaskQueryVO queryVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过重试任务表id获取重试任务信息
|
||||||
|
*
|
||||||
|
* @param groupName 组名称
|
||||||
|
* @param id 重试任务表id
|
||||||
|
* @return 重试任务
|
||||||
|
*/
|
||||||
RetryTaskResponseVO getRetryTaskById(String groupName, Long id);
|
RetryTaskResponseVO getRetryTaskById(String groupName, Long id);
|
||||||
|
|
||||||
int updateRetryTaskStatus(RetryTaskRequestVO retryTaskRequestVO);
|
/**
|
||||||
|
* 更新重试任务状态
|
||||||
|
*
|
||||||
|
* @param retryTaskUpdateStatusRequestVO 更新重试任务状态请求模型
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int updateRetryTaskStatus(RetryTaskUpdateStatusRequestVO retryTaskUpdateStatusRequestVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 手动新增重试任务
|
* 手动新增重试任务
|
||||||
@ -33,8 +47,16 @@ public interface RetryTaskService {
|
|||||||
/**
|
/**
|
||||||
* 委托客户端生成bizId
|
* 委托客户端生成bizId
|
||||||
*
|
*
|
||||||
* @param generateRetryBizIdDTO
|
* @param generateRetryBizIdVO 生成bizId请求模型
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
String bizIdGenerate(GenerateRetryBizIdDTO generateRetryBizIdDTO);
|
String bizIdGenerate(GenerateRetryBizIdVO generateRetryBizIdVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 若客户端在变更了执行器,从而会导致执行重试任务时找不到执行器类,因此使用者可以在后端进行执行变更
|
||||||
|
*
|
||||||
|
* @param requestVO 更新执行器变更模型
|
||||||
|
* @return 更新条数
|
||||||
|
*/
|
||||||
|
int updateRetryTaskExecutorName(RetryTaskUpdateExecutorNameRequestVO requestVO);
|
||||||
}
|
}
|
||||||
|
@ -69,7 +69,7 @@ public class GroupConfigServiceImpl implements GroupConfigService {
|
|||||||
|
|
||||||
Assert.isTrue(groupConfigMapper.selectCount(new LambdaQueryWrapper<GroupConfig>()
|
Assert.isTrue(groupConfigMapper.selectCount(new LambdaQueryWrapper<GroupConfig>()
|
||||||
.eq(GroupConfig::getGroupName, groupConfigRequestVO.getGroupName())) == 0,
|
.eq(GroupConfig::getGroupName, groupConfigRequestVO.getGroupName())) == 0,
|
||||||
new EasyRetryServerException("GroupName已经存在 {}", groupConfigRequestVO.getGroupName()));
|
() -> new EasyRetryServerException("GroupName已经存在 {}", groupConfigRequestVO.getGroupName()));
|
||||||
|
|
||||||
doSaveGroupConfig(groupConfigRequestVO);
|
doSaveGroupConfig(groupConfigRequestVO);
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ public class GroupConfigServiceImpl implements GroupConfigService {
|
|||||||
|
|
||||||
Assert.isTrue(1 == groupConfigMapper.update(groupConfig,
|
Assert.isTrue(1 == groupConfigMapper.update(groupConfig,
|
||||||
new LambdaUpdateWrapper<GroupConfig>().eq(GroupConfig::getGroupName, groupConfigRequestVO.getGroupName())),
|
new LambdaUpdateWrapper<GroupConfig>().eq(GroupConfig::getGroupName, groupConfigRequestVO.getGroupName())),
|
||||||
new EasyRetryServerException("新增组异常异常 groupConfigVO[{}]", groupConfigRequestVO));
|
() -> new EasyRetryServerException("新增组异常异常 groupConfigVO[{}]", groupConfigRequestVO));
|
||||||
|
|
||||||
doUpdateNotifyConfig(groupConfigRequestVO);
|
doUpdateNotifyConfig(groupConfigRequestVO);
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ public class GroupConfigServiceImpl implements GroupConfigService {
|
|||||||
groupConfig.setGroupPartition(HashUtil.bkdrHash(groupConfigRequestVO.getGroupName()) % totalPartition);
|
groupConfig.setGroupPartition(HashUtil.bkdrHash(groupConfigRequestVO.getGroupName()) % totalPartition);
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.isTrue(1 == groupConfigMapper.insert(groupConfig), new EasyRetryServerException("新增组异常异常 groupConfigVO[{}]", groupConfigRequestVO));
|
Assert.isTrue(1 == groupConfigMapper.insert(groupConfig), () -> new EasyRetryServerException("新增组异常异常 groupConfigVO[{}]", groupConfigRequestVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -182,7 +182,7 @@ public class GroupConfigServiceImpl implements GroupConfigService {
|
|||||||
notifyConfig.setCreateDt(LocalDateTime.now());
|
notifyConfig.setCreateDt(LocalDateTime.now());
|
||||||
|
|
||||||
Assert.isTrue(1 == notifyConfigMapper.insert(notifyConfig),
|
Assert.isTrue(1 == notifyConfigMapper.insert(notifyConfig),
|
||||||
new EasyRetryServerException("插入通知配置失败 sceneConfig:[{}]", JsonUtil.toJsonString(notifyConfig)));
|
() -> new EasyRetryServerException("插入通知配置失败 sceneConfig:[{}]", JsonUtil.toJsonString(notifyConfig)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doSaveSceneConfig(List<GroupConfigRequestVO.SceneConfigVO> sceneList, String groupName) {
|
private void doSaveSceneConfig(List<GroupConfigRequestVO.SceneConfigVO> sceneList, String groupName) {
|
||||||
@ -195,7 +195,7 @@ public class GroupConfigServiceImpl implements GroupConfigService {
|
|||||||
sceneConfig.setGroupName(groupName);
|
sceneConfig.setGroupName(groupName);
|
||||||
|
|
||||||
Assert.isTrue(1 == sceneConfigMapper.insert(sceneConfig),
|
Assert.isTrue(1 == sceneConfigMapper.insert(sceneConfig),
|
||||||
new EasyRetryServerException("插入场景配置失败 sceneConfig:[{}]", JsonUtil.toJsonString(sceneConfig)));
|
() -> new EasyRetryServerException("插入场景配置失败 sceneConfig:[{}]", JsonUtil.toJsonString(sceneConfig)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -218,7 +218,7 @@ public class GroupConfigServiceImpl implements GroupConfigService {
|
|||||||
} else if (sceneConfigVO.getIsDeleted() == 1) {
|
} else if (sceneConfigVO.getIsDeleted() == 1) {
|
||||||
Assert.isTrue(
|
Assert.isTrue(
|
||||||
1 == sceneConfigMapper.deleteById(oldSceneConfig.getId()),
|
1 == sceneConfigMapper.deleteById(oldSceneConfig.getId()),
|
||||||
new EasyRetryServerException("删除场景失败 [{}]", sceneConfigVO.getSceneName()));
|
() -> new EasyRetryServerException("删除场景失败 [{}]", sceneConfigVO.getSceneName()));
|
||||||
} else {
|
} else {
|
||||||
SceneConfig sceneConfig = sceneConfigConverter.convert(sceneConfigVO);
|
SceneConfig sceneConfig = sceneConfigConverter.convert(sceneConfigVO);
|
||||||
sceneConfig.setGroupName(groupConfigRequestVO.getGroupName());
|
sceneConfig.setGroupName(groupConfigRequestVO.getGroupName());
|
||||||
@ -227,7 +227,7 @@ public class GroupConfigServiceImpl implements GroupConfigService {
|
|||||||
new LambdaQueryWrapper<SceneConfig>()
|
new LambdaQueryWrapper<SceneConfig>()
|
||||||
.eq(SceneConfig::getGroupName, sceneConfig.getGroupName())
|
.eq(SceneConfig::getGroupName, sceneConfig.getGroupName())
|
||||||
.eq(SceneConfig::getSceneName, sceneConfig.getSceneName())),
|
.eq(SceneConfig::getSceneName, sceneConfig.getSceneName())),
|
||||||
new EasyRetryServerException("插入场景配置失败 sceneConfig:[{}]", JsonUtil.toJsonString(sceneConfig)));
|
() -> new EasyRetryServerException("插入场景配置失败 sceneConfig:[{}]", JsonUtil.toJsonString(sceneConfig)));
|
||||||
}
|
}
|
||||||
|
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
@ -253,7 +253,7 @@ public class GroupConfigServiceImpl implements GroupConfigService {
|
|||||||
} else if (Objects.nonNull(notifyConfigVO.getId()) && notifyConfigVO.getIsDeleted() == 1) {
|
} else if (Objects.nonNull(notifyConfigVO.getId()) && notifyConfigVO.getIsDeleted() == 1) {
|
||||||
// delete
|
// delete
|
||||||
Assert.isTrue(1 == notifyConfigMapper.deleteById(notifyConfigVO.getId()),
|
Assert.isTrue(1 == notifyConfigMapper.deleteById(notifyConfigVO.getId()),
|
||||||
new EasyRetryServerException("删除通知配置失败 sceneConfig:[{}]", JsonUtil.toJsonString(notifyConfigVO)));
|
() -> new EasyRetryServerException("删除通知配置失败 sceneConfig:[{}]", JsonUtil.toJsonString(notifyConfigVO)));
|
||||||
} else {
|
} else {
|
||||||
// update
|
// update
|
||||||
Assert.isTrue(1 == notifyConfigMapper.update(notifyConfig,
|
Assert.isTrue(1 == notifyConfigMapper.update(notifyConfig,
|
||||||
@ -261,7 +261,7 @@ public class GroupConfigServiceImpl implements GroupConfigService {
|
|||||||
.eq(NotifyConfig::getId, notifyConfigVO.getId())
|
.eq(NotifyConfig::getId, notifyConfigVO.getId())
|
||||||
.eq(NotifyConfig::getGroupName, notifyConfig.getGroupName())
|
.eq(NotifyConfig::getGroupName, notifyConfig.getGroupName())
|
||||||
.eq(NotifyConfig::getNotifyScene, notifyConfig.getNotifyScene())),
|
.eq(NotifyConfig::getNotifyScene, notifyConfig.getNotifyScene())),
|
||||||
new EasyRetryServerException("更新通知配置失败 sceneConfig:[{}]", JsonUtil.toJsonString(notifyConfig)));
|
() -> new EasyRetryServerException("更新通知配置失败 sceneConfig:[{}]", JsonUtil.toJsonString(notifyConfig)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,10 +92,10 @@ public class RetryDeadLetterServiceImpl implements RetryDeadLetterService {
|
|||||||
retryTask.setCreateDt(LocalDateTime.now());
|
retryTask.setCreateDt(LocalDateTime.now());
|
||||||
retryTask.setUpdateDt(LocalDateTime.now());
|
retryTask.setUpdateDt(LocalDateTime.now());
|
||||||
RequestDataHelper.setPartition(groupName);
|
RequestDataHelper.setPartition(groupName);
|
||||||
Assert.isTrue(1 == retryTaskMapper.insert(retryTask), new EasyRetryServerException("新增重试任务失败"));
|
Assert.isTrue(1 == retryTaskMapper.insert(retryTask), () -> new EasyRetryServerException("新增重试任务失败"));
|
||||||
|
|
||||||
RequestDataHelper.setPartition(groupName);
|
RequestDataHelper.setPartition(groupName);
|
||||||
Assert.isTrue(1 == retryDeadLetterMapper.deleteById(retryDeadLetter.getId()), new EasyRetryServerException("删除死信队列数据失败"));
|
Assert.isTrue(1 == retryDeadLetterMapper.deleteById(retryDeadLetter.getId()), () -> new EasyRetryServerException("删除死信队列数据失败"));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ public class RetryServiceImpl implements RetryService {
|
|||||||
|
|
||||||
retryTask.setNextTriggerAt(WaitStrategies.randomWait(1, TimeUnit.SECONDS, 60, TimeUnit.SECONDS).computeRetryTime(null));
|
retryTask.setNextTriggerAt(WaitStrategies.randomWait(1, TimeUnit.SECONDS, 60, TimeUnit.SECONDS).computeRetryTime(null));
|
||||||
|
|
||||||
Assert.isTrue(1 == retryTaskAccess.saveRetryTask(retryTask), new EasyRetryServerException("上报数据失败"));
|
Assert.isTrue(1 == retryTaskAccess.saveRetryTask(retryTask), () -> new EasyRetryServerException("上报数据失败"));
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,11 +140,11 @@ public class RetryServiceImpl implements RetryService {
|
|||||||
|
|
||||||
GroupConfig groupConfig = configAccess.getGroupConfigByGroupName(groupName);
|
GroupConfig groupConfig = configAccess.getGroupConfigByGroupName(groupName);
|
||||||
Assert.isTrue(retryDeadLetters.size() == retryDeadLetterMapper.insertBatch(retryDeadLetters, groupConfig.getGroupPartition()),
|
Assert.isTrue(retryDeadLetters.size() == retryDeadLetterMapper.insertBatch(retryDeadLetters, groupConfig.getGroupPartition()),
|
||||||
new EasyRetryServerException("插入死信队列失败 [{}]" , JsonUtil.toJsonString(retryDeadLetters)));
|
() -> new EasyRetryServerException("插入死信队列失败 [{}]" , JsonUtil.toJsonString(retryDeadLetters)));
|
||||||
|
|
||||||
List<Long> ids = retryTasks.stream().map(RetryTask::getId).collect(Collectors.toList());
|
List<Long> ids = retryTasks.stream().map(RetryTask::getId).collect(Collectors.toList());
|
||||||
Assert.isTrue(retryTasks.size() == retryTaskMapper.deleteBatch(ids, groupConfig.getGroupPartition()),
|
Assert.isTrue(retryTasks.size() == retryTaskMapper.deleteBatch(ids, groupConfig.getGroupPartition()),
|
||||||
new EasyRetryServerException("删除重试数据失败 [{}]", JsonUtil.toJsonString(retryTasks)));
|
() -> new EasyRetryServerException("删除重试数据失败 [{}]", JsonUtil.toJsonString(retryTasks)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,30 +1,34 @@
|
|||||||
package com.aizuda.easy.retry.server.service.impl;
|
package com.aizuda.easy.retry.server.service.impl;
|
||||||
|
|
||||||
import com.aizuda.easy.retry.client.model.GenerateRetryBizIdDTO;
|
import com.aizuda.easy.retry.client.model.GenerateRetryBizIdDTO;
|
||||||
|
import com.aizuda.easy.retry.common.core.enums.RetryStatusEnum;
|
||||||
import com.aizuda.easy.retry.common.core.model.Result;
|
import com.aizuda.easy.retry.common.core.model.Result;
|
||||||
import com.aizuda.easy.retry.common.core.util.Assert;
|
import com.aizuda.easy.retry.common.core.util.Assert;
|
||||||
|
import com.aizuda.easy.retry.server.config.RequestDataHelper;
|
||||||
import com.aizuda.easy.retry.server.exception.EasyRetryServerException;
|
import com.aizuda.easy.retry.server.exception.EasyRetryServerException;
|
||||||
import com.aizuda.easy.retry.server.persistence.mybatis.mapper.RetryTaskMapper;
|
import com.aizuda.easy.retry.server.persistence.mybatis.mapper.RetryTaskMapper;
|
||||||
import com.aizuda.easy.retry.server.persistence.mybatis.po.RetryTask;
|
import com.aizuda.easy.retry.server.persistence.mybatis.po.RetryTask;
|
||||||
import com.aizuda.easy.retry.server.persistence.mybatis.po.ServerNode;
|
import com.aizuda.easy.retry.server.persistence.mybatis.po.ServerNode;
|
||||||
|
import com.aizuda.easy.retry.server.service.RetryTaskService;
|
||||||
import com.aizuda.easy.retry.server.service.convert.RetryTaskConverter;
|
import com.aizuda.easy.retry.server.service.convert.RetryTaskConverter;
|
||||||
|
import com.aizuda.easy.retry.server.service.convert.RetryTaskResponseVOConverter;
|
||||||
import com.aizuda.easy.retry.server.support.handler.ClientNodeAllocateHandler;
|
import com.aizuda.easy.retry.server.support.handler.ClientNodeAllocateHandler;
|
||||||
import com.aizuda.easy.retry.server.support.strategy.WaitStrategies;
|
import com.aizuda.easy.retry.server.support.strategy.WaitStrategies;
|
||||||
import com.aizuda.easy.retry.server.web.model.request.RetryTaskSaveRequestVO;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
|
||||||
import com.aizuda.easy.retry.common.core.enums.RetryStatusEnum;
|
|
||||||
import com.aizuda.easy.retry.server.config.RequestDataHelper;
|
|
||||||
import com.aizuda.easy.retry.server.web.model.base.PageResult;
|
import com.aizuda.easy.retry.server.web.model.base.PageResult;
|
||||||
import com.aizuda.easy.retry.server.service.RetryTaskService;
|
import com.aizuda.easy.retry.server.web.model.request.GenerateRetryBizIdVO;
|
||||||
import com.aizuda.easy.retry.server.service.convert.RetryTaskResponseVOConverter;
|
|
||||||
import com.aizuda.easy.retry.server.web.model.request.RetryTaskQueryVO;
|
import com.aizuda.easy.retry.server.web.model.request.RetryTaskQueryVO;
|
||||||
import com.aizuda.easy.retry.server.web.model.request.RetryTaskRequestVO;
|
import com.aizuda.easy.retry.server.web.model.request.RetryTaskUpdateStatusRequestVO;
|
||||||
|
import com.aizuda.easy.retry.server.web.model.request.RetryTaskSaveRequestVO;
|
||||||
|
import com.aizuda.easy.retry.server.web.model.request.RetryTaskUpdateExecutorNameRequestVO;
|
||||||
import com.aizuda.easy.retry.server.web.model.response.RetryTaskResponseVO;
|
import com.aizuda.easy.retry.server.web.model.response.RetryTaskResponseVO;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.HttpEntity;
|
import org.springframework.http.HttpEntity;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
@ -82,8 +86,8 @@ public class RetryTaskServiceImpl implements RetryTaskService {
|
|||||||
RequestDataHelper.setPartition(queryVO.getGroupName());
|
RequestDataHelper.setPartition(queryVO.getGroupName());
|
||||||
|
|
||||||
retryTaskLambdaQueryWrapper.select(RetryTask::getId, RetryTask::getBizNo, RetryTask::getBizId,
|
retryTaskLambdaQueryWrapper.select(RetryTask::getId, RetryTask::getBizNo, RetryTask::getBizId,
|
||||||
RetryTask::getGroupName, RetryTask::getNextTriggerAt, RetryTask::getRetryCount,
|
RetryTask::getGroupName, RetryTask::getNextTriggerAt, RetryTask::getRetryCount,
|
||||||
RetryTask::getRetryStatus, RetryTask::getUpdateDt, RetryTask::getSceneName);
|
RetryTask::getRetryStatus, RetryTask::getUpdateDt, RetryTask::getSceneName);
|
||||||
pageDTO = retryTaskMapper.selectPage(pageDTO, retryTaskLambdaQueryWrapper.orderByDesc(RetryTask::getCreateDt));
|
pageDTO = retryTaskMapper.selectPage(pageDTO, retryTaskLambdaQueryWrapper.orderByDesc(RetryTask::getCreateDt));
|
||||||
return new PageResult<>(pageDTO, retryTaskResponseVOConverter.batchConvert(pageDTO.getRecords()));
|
return new PageResult<>(pageDTO, retryTaskResponseVOConverter.batchConvert(pageDTO.getRecords()));
|
||||||
}
|
}
|
||||||
@ -96,28 +100,29 @@ public class RetryTaskServiceImpl implements RetryTaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int updateRetryTaskStatus(RetryTaskRequestVO retryTaskRequestVO) {
|
public int updateRetryTaskStatus(RetryTaskUpdateStatusRequestVO retryTaskUpdateStatusRequestVO) {
|
||||||
|
|
||||||
RetryStatusEnum retryStatusEnum = RetryStatusEnum.getByStatus(retryTaskRequestVO.getRetryStatus());
|
RetryStatusEnum retryStatusEnum = RetryStatusEnum.getByStatus(retryTaskUpdateStatusRequestVO.getRetryStatus());
|
||||||
if (Objects.isNull(retryStatusEnum)) {
|
if (Objects.isNull(retryStatusEnum)) {
|
||||||
throw new EasyRetryServerException("重试状态错误");
|
throw new EasyRetryServerException("重试状态错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
RequestDataHelper.setPartition(retryTaskRequestVO.getGroupName());
|
RequestDataHelper.setPartition(retryTaskUpdateStatusRequestVO.getGroupName());
|
||||||
RetryTask retryTask = retryTaskMapper.selectById(retryTaskRequestVO.getId());
|
RetryTask retryTask = retryTaskMapper.selectById(retryTaskUpdateStatusRequestVO.getId());
|
||||||
if (Objects.isNull(retryTask)) {
|
if (Objects.isNull(retryTask)) {
|
||||||
throw new EasyRetryServerException("未查询到重试任务");
|
throw new EasyRetryServerException("未查询到重试任务");
|
||||||
}
|
}
|
||||||
|
|
||||||
retryTask.setRetryStatus(retryTaskRequestVO.getRetryStatus());
|
retryTask.setRetryStatus(retryTaskUpdateStatusRequestVO.getRetryStatus());
|
||||||
retryTask.setGroupName(retryTaskRequestVO.getGroupName());
|
retryTask.setGroupName(retryTaskUpdateStatusRequestVO.getGroupName());
|
||||||
|
|
||||||
// 若恢复重试则需要重新计算下次触发时间
|
// 若恢复重试则需要重新计算下次触发时间
|
||||||
if (RetryStatusEnum.RUNNING.getStatus().equals(retryStatusEnum.getStatus())) {
|
if (RetryStatusEnum.RUNNING.getStatus().equals(retryStatusEnum.getStatus())) {
|
||||||
retryTask.setNextTriggerAt(WaitStrategies.randomWait(1, TimeUnit.SECONDS, 60, TimeUnit.SECONDS).computeRetryTime(null));
|
retryTask.setNextTriggerAt(
|
||||||
|
WaitStrategies.randomWait(1, TimeUnit.SECONDS, 60, TimeUnit.SECONDS).computeRetryTime(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
RequestDataHelper.setPartition(retryTaskRequestVO.getGroupName());
|
RequestDataHelper.setPartition(retryTaskUpdateStatusRequestVO.getGroupName());
|
||||||
return retryTaskMapper.updateById(retryTask);
|
return retryTaskMapper.updateById(retryTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,21 +141,57 @@ public class RetryTaskServiceImpl implements RetryTaskService {
|
|||||||
retryTask.setExtAttrs(StringUtils.EMPTY);
|
retryTask.setExtAttrs(StringUtils.EMPTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
retryTask.setNextTriggerAt(WaitStrategies.randomWait(1, TimeUnit.SECONDS, 60, TimeUnit.SECONDS).computeRetryTime(null));
|
retryTask.setNextTriggerAt(
|
||||||
|
WaitStrategies.randomWait(1, TimeUnit.SECONDS, 60, TimeUnit.SECONDS).computeRetryTime(null));
|
||||||
|
|
||||||
|
RequestDataHelper.setPartition(retryTaskRequestVO.getGroupName());
|
||||||
return retryTaskMapper.insert(retryTask);
|
return retryTaskMapper.insert(retryTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String bizIdGenerate(final GenerateRetryBizIdDTO generateRetryBizIdDTO) {
|
public String bizIdGenerate(final GenerateRetryBizIdVO generateRetryBizIdVO) {
|
||||||
ServerNode serverNode = clientNodeAllocateHandler.getServerNode(generateRetryBizIdDTO.getGroup());
|
ServerNode serverNode = clientNodeAllocateHandler.getServerNode(generateRetryBizIdVO.getGroupName());
|
||||||
Assert.notNull(serverNode, () -> new EasyRetryServerException("生成bizId失败: 不存在活跃的客户端节点"));
|
Assert.notNull(serverNode, () -> new EasyRetryServerException("生成bizId失败: 不存在活跃的客户端节点"));
|
||||||
|
|
||||||
// 委托客户端生成bizId
|
// 委托客户端生成bizId
|
||||||
String url = MessageFormat
|
String url = MessageFormat
|
||||||
.format(URL, serverNode.getHostIp(), serverNode.getHostPort().toString(), serverNode.getContextPath());
|
.format(URL, serverNode.getHostIp(), serverNode.getHostPort().toString(), serverNode.getContextPath());
|
||||||
|
|
||||||
|
GenerateRetryBizIdDTO generateRetryBizIdDTO = new GenerateRetryBizIdDTO();
|
||||||
|
generateRetryBizIdDTO.setGroup(generateRetryBizIdVO.getGroupName());
|
||||||
|
generateRetryBizIdDTO.setScene(generateRetryBizIdVO.getSceneName());
|
||||||
|
generateRetryBizIdDTO.setArgsStr(generateRetryBizIdVO.getArgsStr());
|
||||||
|
generateRetryBizIdDTO.setExecutorName(generateRetryBizIdVO.getExecutorName());
|
||||||
|
|
||||||
HttpEntity<GenerateRetryBizIdDTO> requestEntity = new HttpEntity<>(generateRetryBizIdDTO);
|
HttpEntity<GenerateRetryBizIdDTO> requestEntity = new HttpEntity<>(generateRetryBizIdDTO);
|
||||||
Result<String> result = restTemplate.postForObject(url, requestEntity, Result.class);
|
Result<String> result = restTemplate.postForObject(url, requestEntity, Result.class);
|
||||||
|
|
||||||
|
Assert.notNull(result, () -> new EasyRetryServerException("biz生成失败"));
|
||||||
|
Assert.isTrue(1 == result.getStatus(), () -> new EasyRetryServerException("biz生成失败:请确保参数与执行器名称正确"));
|
||||||
|
|
||||||
return result.getData();
|
return result.getData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateRetryTaskExecutorName(final RetryTaskUpdateExecutorNameRequestVO requestVO) {
|
||||||
|
|
||||||
|
RetryTask retryTask = new RetryTask();
|
||||||
|
retryTask.setExecutorName(requestVO.getExecutorName());
|
||||||
|
retryTask.setUpdateDt(LocalDateTime.now());
|
||||||
|
if (!CollectionUtils.isEmpty(requestVO.getIds())) {
|
||||||
|
|
||||||
|
// 根据重试数据id,更新执行器名称
|
||||||
|
RequestDataHelper.setPartition(requestVO.getGroupName());
|
||||||
|
return retryTaskMapper
|
||||||
|
.update(retryTask, new LambdaUpdateWrapper<RetryTask>().in(RetryTask::getId, requestVO.getIds()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新组下面的场景对应的执行器名称
|
||||||
|
RequestDataHelper.setPartition(requestVO.getGroupName());
|
||||||
|
return retryTaskMapper
|
||||||
|
.update(retryTask, new LambdaUpdateWrapper<RetryTask>()
|
||||||
|
.eq(RetryTask::getGroupName, requestVO.getGroupName())
|
||||||
|
.eq(RetryTask::getSceneName, requestVO.getSceneName())
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ public class SystemUserServiceImpl implements SystemUserService {
|
|||||||
systemUser.setPassword(SecureUtil.sha256(requestVO.getPassword()));
|
systemUser.setPassword(SecureUtil.sha256(requestVO.getPassword()));
|
||||||
systemUser.setRole(requestVO.getRole());
|
systemUser.setRole(requestVO.getRole());
|
||||||
|
|
||||||
Assert.isTrue(1 == systemUserMapper.insert(systemUser), new EasyRetryServerException("新增用户失败"));
|
Assert.isTrue(1 == systemUserMapper.insert(systemUser), () -> new EasyRetryServerException("新增用户失败"));
|
||||||
|
|
||||||
// 只添加为普通用户添加权限
|
// 只添加为普通用户添加权限
|
||||||
List<String> groupNameList = requestVO.getGroupNameList();
|
List<String> groupNameList = requestVO.getGroupNameList();
|
||||||
@ -121,7 +121,7 @@ public class SystemUserServiceImpl implements SystemUserService {
|
|||||||
SystemUserPermission systemUserPermission = new SystemUserPermission();
|
SystemUserPermission systemUserPermission = new SystemUserPermission();
|
||||||
systemUserPermission.setSystemUserId(systemUser.getId());
|
systemUserPermission.setSystemUserId(systemUser.getId());
|
||||||
systemUserPermission.setGroupName(groupName);
|
systemUserPermission.setGroupName(groupName);
|
||||||
Assert.isTrue(1 == systemUserPermissionMapper.insert(systemUserPermission), new EasyRetryServerException("新增用户权限失败"));
|
Assert.isTrue(1 == systemUserPermissionMapper.insert(systemUserPermission), () -> new EasyRetryServerException("新增用户权限失败"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ public class SystemUserServiceImpl implements SystemUserService {
|
|||||||
|
|
||||||
systemUser.setRole(requestVO.getRole());
|
systemUser.setRole(requestVO.getRole());
|
||||||
|
|
||||||
Assert.isTrue(1 == systemUserMapper.updateById(systemUser), new EasyRetryServerException("更新用户失败"));
|
Assert.isTrue(1 == systemUserMapper.updateById(systemUser), () -> new EasyRetryServerException("更新用户失败"));
|
||||||
|
|
||||||
// 只添加为普通用户添加权限
|
// 只添加为普通用户添加权限
|
||||||
List<String> groupNameList = requestVO.getGroupNameList();
|
List<String> groupNameList = requestVO.getGroupNameList();
|
||||||
@ -163,7 +163,7 @@ public class SystemUserServiceImpl implements SystemUserService {
|
|||||||
SystemUserPermission systemUserPermission = new SystemUserPermission();
|
SystemUserPermission systemUserPermission = new SystemUserPermission();
|
||||||
systemUserPermission.setSystemUserId(systemUser.getId());
|
systemUserPermission.setSystemUserId(systemUser.getId());
|
||||||
systemUserPermission.setGroupName(groupName);
|
systemUserPermission.setGroupName(groupName);
|
||||||
Assert.isTrue(1 == systemUserPermissionMapper.insert(systemUserPermission), new EasyRetryServerException("更新用户权限失败"));
|
Assert.isTrue(1 == systemUserPermissionMapper.insert(systemUserPermission), () -> new EasyRetryServerException("更新用户权限失败"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ public class ExecUnitActor extends AbstractActor {
|
|||||||
retryTaskLog.setCreateDt(LocalDateTime.now());
|
retryTaskLog.setCreateDt(LocalDateTime.now());
|
||||||
retryTaskLog.setId(null);
|
retryTaskLog.setId(null);
|
||||||
Assert.isTrue(1 == retryTaskLogMapper.insert(retryTaskLog),
|
Assert.isTrue(1 == retryTaskLogMapper.insert(retryTaskLog),
|
||||||
new EasyRetryServerException("新增重试日志失败"));
|
() -> new EasyRetryServerException("新增重试日志失败"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}).build();
|
}).build();
|
||||||
|
@ -91,7 +91,7 @@ public class FailureActor extends AbstractActor {
|
|||||||
RetryTaskLog retryTaskLog = records.get(0);
|
RetryTaskLog retryTaskLog = records.get(0);
|
||||||
retryTaskLog.setRetryStatus(retryTask.getRetryStatus());
|
retryTaskLog.setRetryStatus(retryTask.getRetryStatus());
|
||||||
Assert.isTrue(1 == retryTaskLogMapper.updateById(retryTaskLog),
|
Assert.isTrue(1 == retryTaskLogMapper.updateById(retryTaskLog),
|
||||||
new EasyRetryServerException("更新重试日志失败"));
|
() -> new EasyRetryServerException("更新重试日志失败"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ public class FinishActor extends AbstractActor {
|
|||||||
RetryTaskLog retryTaskLog = records.get(0);
|
RetryTaskLog retryTaskLog = records.get(0);
|
||||||
retryTaskLog.setRetryStatus(retryTask.getRetryStatus());
|
retryTaskLog.setRetryStatus(retryTask.getRetryStatus());
|
||||||
Assert.isTrue(1 == retryTaskLogMapper.updateById(retryTaskLog),
|
Assert.isTrue(1 == retryTaskLogMapper.updateById(retryTaskLog),
|
||||||
new EasyRetryServerException("更新重试日志失败"));
|
() -> new EasyRetryServerException("更新重试日志失败"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package com.aizuda.easy.retry.server.web.controller;
|
package com.aizuda.easy.retry.server.web.controller;
|
||||||
|
|
||||||
import com.aizuda.easy.retry.client.model.GenerateRetryBizIdDTO;
|
|
||||||
import com.aizuda.easy.retry.server.service.RetryTaskService;
|
import com.aizuda.easy.retry.server.service.RetryTaskService;
|
||||||
import com.aizuda.easy.retry.server.web.annotation.LoginRequired;
|
import com.aizuda.easy.retry.server.web.annotation.LoginRequired;
|
||||||
import com.aizuda.easy.retry.server.web.model.base.PageResult;
|
import com.aizuda.easy.retry.server.web.model.base.PageResult;
|
||||||
|
import com.aizuda.easy.retry.server.web.model.request.GenerateRetryBizIdVO;
|
||||||
import com.aizuda.easy.retry.server.web.model.request.RetryTaskQueryVO;
|
import com.aizuda.easy.retry.server.web.model.request.RetryTaskQueryVO;
|
||||||
import com.aizuda.easy.retry.server.web.model.request.RetryTaskRequestVO;
|
import com.aizuda.easy.retry.server.web.model.request.RetryTaskUpdateStatusRequestVO;
|
||||||
import com.aizuda.easy.retry.server.web.model.request.RetryTaskSaveRequestVO;
|
import com.aizuda.easy.retry.server.web.model.request.RetryTaskSaveRequestVO;
|
||||||
|
import com.aizuda.easy.retry.server.web.model.request.RetryTaskUpdateExecutorNameRequestVO;
|
||||||
import com.aizuda.easy.retry.server.web.model.response.RetryTaskResponseVO;
|
import com.aizuda.easy.retry.server.web.model.response.RetryTaskResponseVO;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@ -49,8 +50,8 @@ public class RetryTaskController {
|
|||||||
|
|
||||||
@LoginRequired
|
@LoginRequired
|
||||||
@PutMapping("status")
|
@PutMapping("status")
|
||||||
public int updateRetryTaskStatus(@RequestBody RetryTaskRequestVO retryTaskRequestVO) {
|
public int updateRetryTaskStatus(@RequestBody RetryTaskUpdateStatusRequestVO retryTaskUpdateStatusRequestVO) {
|
||||||
return retryTaskService.updateRetryTaskStatus(retryTaskRequestVO);
|
return retryTaskService.updateRetryTaskStatus(retryTaskUpdateStatusRequestVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@LoginRequired
|
@LoginRequired
|
||||||
@ -61,8 +62,13 @@ public class RetryTaskController {
|
|||||||
|
|
||||||
@LoginRequired
|
@LoginRequired
|
||||||
@PostMapping("/generate/biz-id")
|
@PostMapping("/generate/biz-id")
|
||||||
public String bizIdGenerate(@RequestBody @Validated GenerateRetryBizIdDTO generateRetryBizIdDTO) {
|
public String bizIdGenerate(@RequestBody @Validated GenerateRetryBizIdVO generateRetryBizIdVO) {
|
||||||
return retryTaskService.bizIdGenerate(generateRetryBizIdDTO);
|
return retryTaskService.bizIdGenerate(generateRetryBizIdVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@LoginRequired
|
||||||
|
@PutMapping("/executor-name/batch")
|
||||||
|
public Integer updateRetryTaskExecutorName(@RequestBody @Validated RetryTaskUpdateExecutorNameRequestVO requestVO) {
|
||||||
|
return retryTaskService.updateRetryTaskExecutorName(requestVO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,9 @@ public class RetryTaskSaveRequestVO {
|
|||||||
private String sceneName;
|
private String sceneName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重试ID(同一个场景下正在重试中的bizId不能重复)
|
* 业务id(同一个场景下正在重试中的bizId不能重复)
|
||||||
*/
|
*/
|
||||||
@NotBlank(message = "重试ID不能为空")
|
@NotBlank(message = "业务id不能为空")
|
||||||
private String bizId;
|
private String bizId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.aizuda.easy.retry.server.web.model.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.hibernate.validator.constraints.NotBlank;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新执行器名称
|
||||||
|
*
|
||||||
|
* @author www.byteblogs.com
|
||||||
|
* @date 2022-09-29
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class RetryTaskUpdateExecutorNameRequestVO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组名称
|
||||||
|
*/
|
||||||
|
@NotBlank(message = "groupName 不能为空")
|
||||||
|
private String groupName;
|
||||||
|
|
||||||
|
@NotBlank(message = "scene 不能为空")
|
||||||
|
private String sceneName;
|
||||||
|
|
||||||
|
@NotBlank(message = "executorName 不能为空")
|
||||||
|
private String executorName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重试表id
|
||||||
|
*/
|
||||||
|
private List<Long> ids;
|
||||||
|
|
||||||
|
}
|
@ -3,27 +3,33 @@ package com.aizuda.easy.retry.server.web.model.request;
|
|||||||
import com.aizuda.easy.retry.common.core.enums.RetryStatusEnum;
|
import com.aizuda.easy.retry.common.core.enums.RetryStatusEnum;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* 更新重试任务模型
|
||||||
|
*
|
||||||
* @author www.byteblogs.com
|
* @author www.byteblogs.com
|
||||||
* @date 2022-09-29
|
* @date 2022-09-29
|
||||||
* @since 2.0
|
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class RetryTaskRequestVO {
|
public class RetryTaskUpdateStatusRequestVO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重试状态 {@link RetryStatusEnum}
|
* 重试状态 {@link RetryStatusEnum}
|
||||||
*/
|
*/
|
||||||
|
@NotBlank(message = "重试状态 不能为空")
|
||||||
private Integer retryStatus;
|
private Integer retryStatus;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组名称
|
* 组名称
|
||||||
*/
|
*/
|
||||||
|
@NotBlank(message = "组名称 不能为空")
|
||||||
private String groupName;
|
private String groupName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 重试表id
|
* 重试表id
|
||||||
*/
|
*/
|
||||||
|
@NotBlank(message = "重试表id 不能为空")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
}
|
}
|
@ -7,7 +7,7 @@ import org.springframework.transaction.event.TransactionPhase;
|
|||||||
import org.springframework.transaction.event.TransactionalEventListener;
|
import org.springframework.transaction.event.TransactionalEventListener;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author: shuguang.zhang
|
* @author: www.byteblogs.com
|
||||||
* @date : 2023-04-25 22:46
|
* @date : 2023-04-25 22:46
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
|
Loading…
Reference in New Issue
Block a user