feat: 1.2.0
1. bizId变更为idempotent_id
This commit is contained in:
		
							parent
							
								
									c0614538d4
								
							
						
					
					
						commit
						aa4394ff0d
					
				| @ -35,7 +35,7 @@ CREATE TABLE `retry_dead_letter_0` | ||||
|     `id`            bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', | ||||
|     `group_name`    varchar(64)  NOT NULL COMMENT '组名称', | ||||
|     `scene_name`    varchar(64)  NOT NULL COMMENT '场景id', | ||||
|     `biz_id`        varchar(64)  NOT NULL COMMENT '业务id', | ||||
|     `idempotent_id`        varchar(64)  NOT NULL COMMENT '幂等id', | ||||
|     `biz_no`        varchar(64)  NOT NULL DEFAULT '' COMMENT '业务编号', | ||||
|     `executor_name` varchar(512) NOT NULL DEFAULT '' COMMENT '执行器名称', | ||||
|     `args_str`      text         NOT NULL COMMENT '执行方法参数', | ||||
| @ -43,7 +43,7 @@ CREATE TABLE `retry_dead_letter_0` | ||||
|     `create_dt`     datetime     NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | ||||
|     PRIMARY KEY (`id`), | ||||
|     KEY             `idx_group_name_scene_name` (`group_name`, `scene_name`), | ||||
|     KEY             `idx_biz_id` (`biz_id`), | ||||
|     KEY             `idx_idempotent_id` (`idempotent_id`), | ||||
|     KEY             `idx_biz_no` (`biz_no`) | ||||
| ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COMMENT='重试死信队列' | ||||
| ; | ||||
| @ -53,7 +53,7 @@ CREATE TABLE `retry_task_0` | ||||
|     `id`              bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', | ||||
|     `group_name`      varchar(64)  NOT NULL COMMENT '组名称', | ||||
|     `scene_name`      varchar(64)  NOT NULL COMMENT '场景名称', | ||||
|     `biz_id`          varchar(64)  NOT NULL COMMENT '业务id', | ||||
|     `idempotent_id`          varchar(64)  NOT NULL COMMENT '幂等id', | ||||
|     `biz_no`          varchar(64)  NOT NULL DEFAULT '' COMMENT '业务编号', | ||||
|     `executor_name`   varchar(512) NOT NULL DEFAULT '' COMMENT '执行器名称', | ||||
|     `args_str`        text         NOT NULL COMMENT '执行方法参数', | ||||
| @ -66,7 +66,7 @@ CREATE TABLE `retry_task_0` | ||||
|     PRIMARY KEY (`id`), | ||||
|     KEY             `idx_group_name_scene_name` (`group_name`, `scene_name`), | ||||
|     KEY             `idx_retry_status` (`retry_status`), | ||||
|     KEY             `idx_biz_id` (`biz_id`) | ||||
|     KEY             `idx_idempotent_id` (`idempotent_id`) | ||||
| ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COMMENT='重试表' | ||||
| ; | ||||
| 
 | ||||
| @ -75,7 +75,7 @@ CREATE TABLE `retry_task_log` | ||||
|     `id`            bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键', | ||||
|     `group_name`    varchar(64)  NOT NULL COMMENT '组名称', | ||||
|     `scene_name`    varchar(64)  NOT NULL COMMENT '场景名称', | ||||
|     `biz_id`        varchar(64)  NOT NULL COMMENT '业务id', | ||||
|     `idempotent_id`        varchar(64)  NOT NULL COMMENT '幂等id', | ||||
|     `biz_no`        varchar(64)  NOT NULL DEFAULT '' COMMENT '业务编号', | ||||
|     `executor_name` varchar(512) NOT NULL DEFAULT '' COMMENT '执行器名称', | ||||
|     `args_str`      text         NOT NULL COMMENT '执行方法参数', | ||||
| @ -87,7 +87,7 @@ CREATE TABLE `retry_task_log` | ||||
|     PRIMARY KEY (`id`), | ||||
|     KEY             `idx_group_name_scene_name` (`group_name`, `scene_name`), | ||||
|     KEY             `idx_retry_status` (`retry_status`), | ||||
|     KEY             `idx_biz_id` (`biz_id`) | ||||
|     KEY             `idx_idempotent_id` (`idempotent_id`) | ||||
| ) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 COMMENT='重试日志表' | ||||
| ; | ||||
| 
 | ||||
|  | ||||
| @ -1,33 +0,0 @@ | ||||
| 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 | ||||
|  * @date : 2022-03-08 09:42 | ||||
|  */ | ||||
| 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; | ||||
| } | ||||
| @ -0,0 +1,33 @@ | ||||
| package com.aizuda.easy.retry.client.core; | ||||
| 
 | ||||
| /** | ||||
|  * 幂等id生成器 | ||||
|  * 同一个组的同一个场景下只会存在一个相同的idempotentId重试任务, 若存在相同的则上报服务后会被幂等处理 | ||||
|  * 比如: | ||||
|  * 组: AGroup | ||||
|  * 场景: BScene | ||||
|  * 时刻1: 上报一个异常 idempotentId: A1 状态为重试中 | ||||
|  * 时刻2: 上报一个异常 idempotentId: A2 状态为重试中,可以上报成功,此时存在两个重试任务 | ||||
|  * 时刻3: 上报一个异常 idempotentId: A1 不会新增一个重试任务,会被幂等处理 | ||||
|  * 时刻4:  idempotentId: A1 重试完成, 状态为已完成 | ||||
|  * 时刻5: 上报一个异常 idempotentId: A1 状态为重试中, 新增一条重试任务 | ||||
|  * | ||||
|  * @author: www.byteblogs.com | ||||
|  * @date : 2022-03-08 09:42 | ||||
|  */ | ||||
| public interface IdempotentIdGenerate { | ||||
| 
 | ||||
|     /** | ||||
|      * 参数列表为Object一维数组, 下面说明每一个下标代表的数据含义 | ||||
|      * 0: 场景名称: scene(String) | ||||
|      * 1: 执行器名称: targetClassName(String) | ||||
|      * 2: 参数列表: args(Object[]) | ||||
|      * 3: 执行的方法名称: methodName(String) | ||||
|      * scene, targetClassName, args, executorMethod.getName() | ||||
|      * | ||||
|      * @param t 参数列表 | ||||
|      * @return idempotentId | ||||
|      * @throws Exception | ||||
|      */ | ||||
|     String idGenerate(Object... t) throws Exception; | ||||
| } | ||||
| @ -1,8 +1,8 @@ | ||||
| package com.aizuda.easy.retry.client.core.annotation; | ||||
| 
 | ||||
| 
 | ||||
| import com.aizuda.easy.retry.client.core.BizIdGenerate; | ||||
| import com.aizuda.easy.retry.client.core.generator.SimpleBizIdGenerate; | ||||
| import com.aizuda.easy.retry.client.core.IdempotentIdGenerate; | ||||
| import com.aizuda.easy.retry.client.core.generator.SimpleIdempotentIdGenerate; | ||||
| import com.aizuda.easy.retry.client.core.strategy.RetryAnnotationMethod; | ||||
| import com.aizuda.easy.retry.client.core.callback.RetryCompleteCallback; | ||||
| import com.aizuda.easy.retry.client.core.callback.SimpleRetryCompleteCallback; | ||||
| @ -49,22 +49,22 @@ public @interface Retryable { | ||||
|     Class<? extends RetryMethod> retryMethod() default RetryAnnotationMethod.class; | ||||
| 
 | ||||
|     /** | ||||
|      * 业务id生成器 | ||||
|      * 同一个组的同一个场景下只会存在一个相同的bizId并且状态为'重试中'的任务, 若存在相同的则上报服务后会被幂等处理 | ||||
|      * 幂等id生成器 | ||||
|      * 同一个组的同一个场景下只会存在一个相同的idempotentId并且状态为'重试中'的任务, 若存在相同的则上报服务后会被幂等处理 | ||||
|      * 比如: | ||||
|      * 组: AGroup | ||||
|      * 场景: BScene | ||||
|      * 时刻1: 上报一个异常 bizId: A1 状态为重试中 | ||||
|      * 时刻2: 上报一个异常 bizId: A2 状态为重试中,可以上报成功,此时存在两个重试任务 | ||||
|      * 时刻3: 上报一个异常 bizId: A1 不会新增一个重试任务,会被幂等处理 | ||||
|      * 时刻4:  bizId: A1 重试完成, 状态为已完成 | ||||
|      * 时刻5: 上报一个异常 bizId: A1 状态为重试中, 新增一条重试任务 | ||||
|      * 时刻1: 上报一个异常 idempotentId: A1 状态为重试中 | ||||
|      * 时刻2: 上报一个异常 idempotentId: A2 状态为重试中,可以上报成功,此时存在两个重试任务 | ||||
|      * 时刻3: 上报一个异常 idempotentId: A1 不会新增一个重试任务,会被幂等处理 | ||||
|      * 时刻4:  idempotentId: A1 重试完成, 状态为已完成 | ||||
|      * 时刻5: 上报一个异常 idempotentId: A1 状态为重试中, 新增一条重试任务 | ||||
|      ** | ||||
|      * 默认的bizId生成器{@link SimpleBizIdGenerate} 对所有参数进行MD5 | ||||
|      * 默认的idempotentId生成器{@link SimpleIdempotentIdGenerate} 对所有参数进行MD5 | ||||
|      * | ||||
|      * @return bizId | ||||
|      * @return idempotentId | ||||
|      */ | ||||
|     Class<? extends BizIdGenerate> bizId() default SimpleBizIdGenerate.class; | ||||
|     Class<? extends IdempotentIdGenerate> idempotentId() default SimpleIdempotentIdGenerate.class; | ||||
| 
 | ||||
|     /** | ||||
|      * 服务端重试完成(重试成功、重试到达最大次数)回调客户端 | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| package com.aizuda.easy.retry.client.core.client; | ||||
| 
 | ||||
| import cn.hutool.core.lang.Assert; | ||||
| import com.aizuda.easy.retry.client.core.BizIdGenerate; | ||||
| import com.aizuda.easy.retry.client.core.IdempotentIdGenerate; | ||||
| import com.aizuda.easy.retry.client.core.RetryArgSerializer; | ||||
| import com.aizuda.easy.retry.client.core.cache.GroupVersionCache; | ||||
| import com.aizuda.easy.retry.client.core.cache.RetryerInfoCache; | ||||
| @ -12,7 +12,7 @@ import com.aizuda.easy.retry.client.core.retryer.RetryerInfo; | ||||
| import com.aizuda.easy.retry.client.core.retryer.RetryerResultContext; | ||||
| import com.aizuda.easy.retry.client.core.serializer.JacksonSerializer; | ||||
| import com.aizuda.easy.retry.client.core.strategy.RetryStrategy; | ||||
| import com.aizuda.easy.retry.client.model.GenerateRetryBizIdDTO; | ||||
| import com.aizuda.easy.retry.client.model.GenerateRetryIdempotentIdDTO; | ||||
| import com.aizuda.easy.retry.common.core.context.SpringContext; | ||||
| import com.aizuda.easy.retry.common.core.enums.RetryResultStatusEnum; | ||||
| import com.aizuda.easy.retry.common.core.enums.RetryStatusEnum; | ||||
| @ -87,7 +87,7 @@ public class RetryEndPoint { | ||||
|                 executeRespDto.setExceptionMsg(retryerResultContext.getMessage()); | ||||
|             } | ||||
| 
 | ||||
|             executeRespDto.setBizId(executeReqDto.getBizId()); | ||||
|             executeRespDto.setIdempotentId(executeReqDto.getIdempotentId()); | ||||
|             if (Objects.nonNull(retryerResultContext.getResult())) { | ||||
|                 executeRespDto.setResultJson(JsonUtil.toJsonString(retryerResultContext.getResult())); | ||||
|             } | ||||
| @ -140,17 +140,17 @@ public class RetryEndPoint { | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 手动新增重试数据,模拟生成bizId | ||||
|      * 手动新增重试数据,模拟生成idempotentId | ||||
|      * | ||||
|      * @param generateRetryBizIdDTO 生成bizId模型 | ||||
|      * @return bizId | ||||
|      * @param generateRetryIdempotentIdDTO 生成idempotentId模型 | ||||
|      * @return idempotentId | ||||
|      */ | ||||
|     @PostMapping("/generate/biz-id/v1") | ||||
|     public Result<String> bizIdGenerate(@RequestBody @Validated GenerateRetryBizIdDTO generateRetryBizIdDTO) { | ||||
|     @PostMapping("/generate/idempotent-id/v1") | ||||
|     public Result<String> idempotentIdGenerate(@RequestBody @Validated GenerateRetryIdempotentIdDTO generateRetryIdempotentIdDTO) { | ||||
| 
 | ||||
|         String scene = generateRetryBizIdDTO.getScene(); | ||||
|         String executorName = generateRetryBizIdDTO.getExecutorName(); | ||||
|         String argsStr = generateRetryBizIdDTO.getArgsStr(); | ||||
|         String scene = generateRetryIdempotentIdDTO.getScene(); | ||||
|         String executorName = generateRetryIdempotentIdDTO.getExecutorName(); | ||||
|         String argsStr = generateRetryIdempotentIdDTO.getArgsStr(); | ||||
| 
 | ||||
|         RetryerInfo retryerInfo = RetryerInfoCache.get(scene, executorName); | ||||
|         Assert.notNull(retryerInfo, ()-> new EasyRetryClientException("重试信息不存在 scene:[{}] executorName:[{}]", scene, executorName)); | ||||
| @ -166,18 +166,18 @@ public class RetryEndPoint { | ||||
|             throw new EasyRetryClientException("参数解析异常", e); | ||||
|         } | ||||
| 
 | ||||
|         String bizId; | ||||
|         String idempotentId; | ||||
|         try { | ||||
|             Class<? extends BizIdGenerate> bizIdGenerate = retryerInfo.getBizIdGenerate(); | ||||
|             BizIdGenerate generate = bizIdGenerate.newInstance(); | ||||
|             Method method = bizIdGenerate.getMethod("idGenerate", Object[].class); | ||||
|             Class<? extends IdempotentIdGenerate> idempotentIdGenerate = retryerInfo.getIdempotentIdGenerate(); | ||||
|             IdempotentIdGenerate generate = idempotentIdGenerate.newInstance(); | ||||
|             Method method = idempotentIdGenerate.getMethod("idGenerate", Object[].class); | ||||
|             Object p = new Object[]{scene, executorName, deSerialize, executorMethod.getName()}; | ||||
|             bizId = (String) ReflectionUtils.invokeMethod(method, generate, p); | ||||
|             idempotentId = (String) ReflectionUtils.invokeMethod(method, generate, p); | ||||
|         } catch (Exception exception) { | ||||
|             LogUtils.error(log, "自定义id生成异常:{},{}", scene, argsStr, exception); | ||||
|             throw new EasyRetryClientException("bizId生成异常:{},{}", scene, argsStr); | ||||
|             LogUtils.error(log, "幂等id生成异常:{},{}", scene, argsStr, exception); | ||||
|             throw new EasyRetryClientException("idempotentId生成异常:{},{}", scene, argsStr); | ||||
|         } | ||||
| 
 | ||||
|         return new Result<>(bizId); | ||||
|         return new Result<>(idempotentId); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,16 +1,16 @@ | ||||
| package com.aizuda.easy.retry.client.core.generator; | ||||
| 
 | ||||
| import cn.hutool.crypto.SecureUtil; | ||||
| import com.aizuda.easy.retry.client.core.BizIdGenerate; | ||||
| import com.aizuda.easy.retry.client.core.IdempotentIdGenerate; | ||||
| import com.aizuda.easy.retry.common.core.util.JsonUtil; | ||||
| 
 | ||||
| /** | ||||
|  * 默认的bizId 生成器 | ||||
|  * 默认的idempotentId 生成器 | ||||
|  * | ||||
|  * @author: www.byteblogs.com | ||||
|  * @date : 2022-03-08 09:42 | ||||
|  */ | ||||
| public class SimpleBizIdGenerate implements BizIdGenerate { | ||||
| public class SimpleIdempotentIdGenerate implements IdempotentIdGenerate { | ||||
| 
 | ||||
|     @Override | ||||
|     public String idGenerate(Object... t) throws Exception { | ||||
| @ -1,6 +1,6 @@ | ||||
| package com.aizuda.easy.retry.client.core.register.scan; | ||||
| 
 | ||||
| import com.aizuda.easy.retry.client.core.BizIdGenerate; | ||||
| import com.aizuda.easy.retry.client.core.IdempotentIdGenerate; | ||||
| import com.aizuda.easy.retry.client.core.Scanner; | ||||
| import com.aizuda.easy.retry.client.core.annotation.Retryable; | ||||
| import com.aizuda.easy.retry.client.core.callback.RetryCompleteCallback; | ||||
| @ -72,7 +72,7 @@ public class RetryableScanner implements Scanner, ApplicationContextAware { | ||||
| 
 | ||||
|         Class executorNotProxy = AopUtils.getTargetClass(executor); | ||||
|         String executorClassName = executorNotProxy.getName(); | ||||
|         Class<? extends BizIdGenerate> bizIdGenerate = retryable.bizId(); | ||||
|         Class<? extends IdempotentIdGenerate> idempotentIdGenerate = retryable.idempotentId(); | ||||
|         String bizNo = retryable.bizNo(); | ||||
|         RetryType retryType = retryable.retryStrategy(); | ||||
|         int localTimes = retryable.localTimes(); | ||||
| @ -90,7 +90,7 @@ public class RetryableScanner implements Scanner, ApplicationContextAware { | ||||
|                 retryType, | ||||
|                 localTimes, | ||||
|                 localInterval, | ||||
|                 bizIdGenerate, | ||||
|                 idempotentIdGenerate, | ||||
|                 bizNo, | ||||
|                 retryMethod, | ||||
|                 throwException, | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| package com.aizuda.easy.retry.client.core.report; | ||||
| 
 | ||||
| import com.aizuda.easy.retry.client.core.BizIdGenerate; | ||||
| import com.aizuda.easy.retry.client.core.IdempotentIdGenerate; | ||||
| import com.aizuda.easy.retry.client.core.RetryArgSerializer; | ||||
| import com.aizuda.easy.retry.client.core.config.EasyRetryProperties; | ||||
| import com.aizuda.easy.retry.client.core.Lifecycle; | ||||
| @ -60,20 +60,20 @@ public class ReportHandler implements Lifecycle { | ||||
|         Method executorMethod = retryerInfo.getExecutorMethod(); | ||||
| 
 | ||||
|         RetryTaskDTO retryTaskDTO = new RetryTaskDTO(); | ||||
|         String bizId; | ||||
|         String idempotentId; | ||||
|         try { | ||||
|             Class<? extends BizIdGenerate> bizIdGenerate = retryerInfo.getBizIdGenerate(); | ||||
|             BizIdGenerate generate = bizIdGenerate.newInstance(); | ||||
|             Method method = bizIdGenerate.getMethod("idGenerate", Object[].class); | ||||
|             Class<? extends IdempotentIdGenerate> idempotentIdGenerate = retryerInfo.getIdempotentIdGenerate(); | ||||
|             IdempotentIdGenerate generate = idempotentIdGenerate.newInstance(); | ||||
|             Method method = idempotentIdGenerate.getMethod("idGenerate", Object[].class); | ||||
|             Object p = new Object[]{scene, targetClassName, args, executorMethod.getName()}; | ||||
|             bizId = (String) ReflectionUtils.invokeMethod(method, generate, p); | ||||
|             idempotentId = (String) ReflectionUtils.invokeMethod(method, generate, p); | ||||
|         } catch (Exception exception) { | ||||
|             LogUtils.error(log, "自定义id生成异常:{},{}", scene, args, exception); | ||||
|             throw new EasyRetryClientException("bizId生成异常:{},{}", scene, args); | ||||
|             LogUtils.error(log, "幂等id生成异常:{},{}", scene, args, exception); | ||||
|             throw new EasyRetryClientException("idempotentId生成异常:{},{}", scene, args); | ||||
|         } | ||||
| 
 | ||||
|         String serialize = retryArgSerializer.serialize(args); | ||||
|         retryTaskDTO.setBizId(bizId); | ||||
|         retryTaskDTO.setIdempotentId(idempotentId); | ||||
|         retryTaskDTO.setExecutorName(targetClassName); | ||||
|         retryTaskDTO.setArgsStr(serialize); | ||||
|         retryTaskDTO.setGroupName(EasyRetryProperties.getGroup()); | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| package com.aizuda.easy.retry.client.core.retryer; | ||||
| 
 | ||||
| import com.aizuda.easy.retry.client.core.BizIdGenerate; | ||||
| import com.aizuda.easy.retry.client.core.IdempotentIdGenerate; | ||||
| import com.aizuda.easy.retry.client.core.strategy.RetryMethod; | ||||
| import com.aizuda.easy.retry.client.core.callback.RetryCompleteCallback; | ||||
| import lombok.AllArgsConstructor; | ||||
| @ -26,7 +26,7 @@ public class RetryerInfo { | ||||
|     private final RetryType retryType; | ||||
|     private final Integer localTimes; | ||||
|     private final Integer localInterval; | ||||
|     private final Class<? extends BizIdGenerate> bizIdGenerate; | ||||
|     private final Class<? extends IdempotentIdGenerate> idempotentIdGenerate; | ||||
|     private final String bizNo; | ||||
|     private final Class<? extends RetryMethod> retryMethod; | ||||
|     private final boolean isThrowException; | ||||
|  | ||||
| @ -15,8 +15,8 @@ public class DispatchRetryDTO { | ||||
|     private String scene; | ||||
|     @NotBlank(message = "参数 不能为空") | ||||
|     private String argsStr; | ||||
|     @NotBlank(message = "bizId 不能为空") | ||||
|     private String bizId; | ||||
|     @NotBlank(message = "idempotentId 不能为空") | ||||
|     private String idempotentId; | ||||
|     @NotBlank(message = "executorName 不能为空") | ||||
|     private String executorName; | ||||
| } | ||||
|  | ||||
| @ -11,6 +11,6 @@ import lombok.Data; | ||||
| public class DispatchRetryResultDTO { | ||||
|     private String resultJson; | ||||
|     private Integer statusCode; | ||||
|     private String bizId; | ||||
|     private String idempotentId; | ||||
|     private String exceptionMsg; | ||||
| } | ||||
|  | ||||
| @ -4,13 +4,13 @@ import lombok.Data; | ||||
| import org.hibernate.validator.constraints.NotBlank; | ||||
| 
 | ||||
| /** | ||||
|  * 生成bizId模型 | ||||
|  * 生成idempotentId模型 | ||||
|  * | ||||
|  * @auther www.byteblogs.com | ||||
|  * @date 2022/03/25 10:06 | ||||
|  */ | ||||
| @Data | ||||
| public class GenerateRetryBizIdDTO { | ||||
| public class GenerateRetryIdempotentIdDTO { | ||||
|     @NotBlank(message = "group 不能为空") | ||||
|     private String group; | ||||
|     @NotBlank(message = "scene 不能为空") | ||||
| @ -17,8 +17,8 @@ public class RetryCallbackDTO { | ||||
|     private String scene; | ||||
|     @NotBlank(message = "参数 不能为空") | ||||
|     private String argsStr; | ||||
|     @NotBlank(message = "bizId 不能为空") | ||||
|     private String bizId; | ||||
|     @NotBlank(message = "idempotentId 不能为空") | ||||
|     private String idempotentId; | ||||
|     @NotBlank(message = "executorName 不能为空") | ||||
|     private String executorName; | ||||
|     @NotBlank(message = "retryStatus 不能为空") | ||||
|  | ||||
| @ -32,9 +32,9 @@ public class RetryTaskDTO implements Serializable { | ||||
|     /** | ||||
|      * 业务唯一id | ||||
|      */ | ||||
|     @NotBlank(message = "bizId 不能为空") | ||||
|     @Length(max = 64, message = "业务唯一id最长为64") | ||||
|     private String bizId; | ||||
|     @NotBlank(message = "idempotentId 不能为空") | ||||
|     @Length(max = 64, message = "幂等id最长为64") | ||||
|     private String idempotentId; | ||||
| 
 | ||||
|     /** | ||||
|      * 执行器名称 | ||||
|  | ||||
| @ -17,7 +17,7 @@ public class RetryDeadLetter implements Serializable { | ||||
| 
 | ||||
|     private String sceneName; | ||||
| 
 | ||||
|     private String bizId; | ||||
|     private String idempotentId; | ||||
| 
 | ||||
|     private String bizNo; | ||||
| 
 | ||||
|  | ||||
| @ -19,7 +19,7 @@ public class RetryTask implements Serializable { | ||||
| 
 | ||||
|     private String sceneName; | ||||
| 
 | ||||
|     private String bizId; | ||||
|     private String idempotentId; | ||||
| 
 | ||||
|     private String bizNo; | ||||
| 
 | ||||
| @ -41,4 +41,4 @@ public class RetryTask implements Serializable { | ||||
| 
 | ||||
|     private static final long serialVersionUID = 1L; | ||||
| 
 | ||||
| } | ||||
| } | ||||
|  | ||||
| @ -17,7 +17,7 @@ public class RetryTaskLog implements Serializable { | ||||
| 
 | ||||
|     private String sceneName; | ||||
| 
 | ||||
|     private String bizId; | ||||
|     private String idempotentId; | ||||
| 
 | ||||
|     private String bizNo; | ||||
| 
 | ||||
|  | ||||
| @ -2,7 +2,7 @@ package com.aizuda.easy.retry.server.service; | ||||
| 
 | ||||
| import com.aizuda.easy.retry.server.web.model.base.PageResult; | ||||
| import com.aizuda.easy.retry.server.web.model.request.BatchDeleteRetryTaskVO; | ||||
| import com.aizuda.easy.retry.server.web.model.request.GenerateRetryBizIdVO; | ||||
| import com.aizuda.easy.retry.server.web.model.request.GenerateRetryIdempotentIdVO; | ||||
| import com.aizuda.easy.retry.server.web.model.request.RetryTaskQueryVO; | ||||
| import com.aizuda.easy.retry.server.web.model.request.RetryTaskUpdateStatusRequestVO; | ||||
| import com.aizuda.easy.retry.server.web.model.request.RetryTaskSaveRequestVO; | ||||
| @ -46,12 +46,12 @@ public interface RetryTaskService { | ||||
|     int saveRetryTask(RetryTaskSaveRequestVO retryTaskRequestVO); | ||||
| 
 | ||||
|     /** | ||||
|      * 委托客户端生成bizId | ||||
|      * 委托客户端生成idempotentId | ||||
|      * | ||||
|      * @param generateRetryBizIdVO 生成bizId请求模型 | ||||
|      * @param generateRetryIdempotentIdVO 生成idempotentId请求模型 | ||||
|      * @return | ||||
|      */ | ||||
|     String bizIdGenerate(GenerateRetryBizIdVO generateRetryBizIdVO); | ||||
|     String idempotentIdGenerate(GenerateRetryIdempotentIdVO generateRetryIdempotentIdVO); | ||||
| 
 | ||||
|     /** | ||||
|      * 若客户端在变更了执行器,从而会导致执行重试任务时找不到执行器类,因此使用者可以在后端进行执行变更 | ||||
|  | ||||
| @ -61,8 +61,8 @@ public class RetryDeadLetterServiceImpl implements RetryDeadLetterService { | ||||
|             retryDeadLetterLambdaQueryWrapper.eq(RetryDeadLetter::getBizNo, queryVO.getBizNo()); | ||||
|         } | ||||
| 
 | ||||
|         if (StringUtils.isNotBlank(queryVO.getBizId())) { | ||||
|             retryDeadLetterLambdaQueryWrapper.eq(RetryDeadLetter::getBizId, queryVO.getBizId()); | ||||
|         if (StringUtils.isNotBlank(queryVO.getIdempotentId())) { | ||||
|             retryDeadLetterLambdaQueryWrapper.eq(RetryDeadLetter::getIdempotentId, queryVO.getIdempotentId()); | ||||
|         } | ||||
| 
 | ||||
|         RequestDataHelper.setPartition(queryVO.getGroupName()); | ||||
|  | ||||
| @ -71,7 +71,7 @@ public class RetryServiceImpl implements RetryService { | ||||
|         RequestDataHelper.setPartition(retryTaskDTO.getGroupName()); | ||||
|         // 此处做幂等处理,避免客户端重复多次上报 | ||||
|         long count = retryTaskMapper.selectCount(new LambdaQueryWrapper<RetryTask>() | ||||
|                 .eq(RetryTask::getBizId, retryTaskDTO.getBizId()) | ||||
|                 .eq(RetryTask::getIdempotentId, retryTaskDTO.getIdempotentId()) | ||||
|                 .eq(RetryTask::getGroupName, retryTaskDTO.getGroupName()) | ||||
|                 .eq(RetryTask::getSceneName, retryTaskDTO.getSceneName()) | ||||
|                 .eq(RetryTask::getRetryStatus, RetryStatusEnum.RUNNING.getStatus()) | ||||
|  | ||||
| @ -26,7 +26,7 @@ public class RetryTaskLogServiceImpl implements RetryTaskLogService { | ||||
|     private RetryTaskLogMapper retryTaskLogMapper; | ||||
| 
 | ||||
|     private RetryTaskLogResponseVOConverter retryTaskLogResponseVOConverter = new RetryTaskLogResponseVOConverter(); | ||||
|      | ||||
| 
 | ||||
|     @Override | ||||
|     public PageResult<List<RetryTaskLogResponseVO>> getRetryTaskLogPage(RetryTaskLogQueryVO queryVO) { | ||||
| 
 | ||||
| @ -42,12 +42,12 @@ public class RetryTaskLogServiceImpl implements RetryTaskLogService { | ||||
|         if (StringUtils.isNotBlank(queryVO.getBizNo())) { | ||||
|             retryTaskLogLambdaQueryWrapper.eq(RetryTaskLog::getBizNo, queryVO.getBizNo()); | ||||
|         } | ||||
|         if (StringUtils.isNotBlank(queryVO.getBizId())) { | ||||
|             retryTaskLogLambdaQueryWrapper.eq(RetryTaskLog::getBizId, queryVO.getBizId()); | ||||
|         if (StringUtils.isNotBlank(queryVO.getIdempotentId())) { | ||||
|             retryTaskLogLambdaQueryWrapper.eq(RetryTaskLog::getIdempotentId, queryVO.getIdempotentId()); | ||||
|         } | ||||
| 
 | ||||
|         retryTaskLogLambdaQueryWrapper.select(RetryTaskLog::getGroupName, RetryTaskLog::getId, RetryTaskLog::getSceneName, | ||||
|                 RetryTaskLog::getBizId, RetryTaskLog::getBizNo, RetryTaskLog::getErrorMessage, RetryTaskLog::getRetryStatus, RetryTaskLog::getCreateDt); | ||||
|                 RetryTaskLog::getIdempotentId, RetryTaskLog::getBizNo, RetryTaskLog::getErrorMessage, RetryTaskLog::getRetryStatus, RetryTaskLog::getCreateDt); | ||||
|         PageDTO<RetryTaskLog> retryTaskLogPageDTO = retryTaskLogMapper.selectPage(pageDTO, retryTaskLogLambdaQueryWrapper.orderByDesc(RetryTaskLog::getCreateDt)); | ||||
| 
 | ||||
|         return new PageResult<>( | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| package com.aizuda.easy.retry.server.service.impl; | ||||
| 
 | ||||
| import cn.hutool.core.lang.Assert; | ||||
| import com.aizuda.easy.retry.client.model.GenerateRetryBizIdDTO; | ||||
| import com.aizuda.easy.retry.client.model.GenerateRetryIdempotentIdDTO; | ||||
| import com.aizuda.easy.retry.common.core.enums.RetryStatusEnum; | ||||
| import com.aizuda.easy.retry.common.core.model.Result; | ||||
| import com.aizuda.easy.retry.server.config.RequestDataHelper; | ||||
| @ -16,7 +16,7 @@ import com.aizuda.easy.retry.server.support.handler.ClientNodeAllocateHandler; | ||||
| import com.aizuda.easy.retry.server.support.strategy.WaitStrategies; | ||||
| import com.aizuda.easy.retry.server.web.model.base.PageResult; | ||||
| import com.aizuda.easy.retry.server.web.model.request.BatchDeleteRetryTaskVO; | ||||
| import com.aizuda.easy.retry.server.web.model.request.GenerateRetryBizIdVO; | ||||
| import com.aizuda.easy.retry.server.web.model.request.GenerateRetryIdempotentIdVO; | ||||
| import com.aizuda.easy.retry.server.web.model.request.RetryTaskQueryVO; | ||||
| import com.aizuda.easy.retry.server.web.model.request.RetryTaskUpdateStatusRequestVO; | ||||
| import com.aizuda.easy.retry.server.web.model.request.RetryTaskSaveRequestVO; | ||||
| @ -29,7 +29,6 @@ import org.apache.commons.lang.StringUtils; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.http.HttpEntity; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.util.CollectionUtils; | ||||
| import org.springframework.web.client.RestTemplate; | ||||
| 
 | ||||
| import java.text.MessageFormat; | ||||
| @ -77,8 +76,8 @@ public class RetryTaskServiceImpl implements RetryTaskService { | ||||
|         if (StringUtils.isNotBlank(queryVO.getBizNo())) { | ||||
|             retryTaskLambdaQueryWrapper.eq(RetryTask::getBizNo, queryVO.getBizNo()); | ||||
|         } | ||||
|         if (StringUtils.isNotBlank(queryVO.getBizId())) { | ||||
|             retryTaskLambdaQueryWrapper.eq(RetryTask::getBizId, queryVO.getBizId()); | ||||
|         if (StringUtils.isNotBlank(queryVO.getIdempotentId())) { | ||||
|             retryTaskLambdaQueryWrapper.eq(RetryTask::getIdempotentId, queryVO.getIdempotentId()); | ||||
|         } | ||||
|         if (Objects.nonNull(queryVO.getRetryStatus())) { | ||||
|             retryTaskLambdaQueryWrapper.eq(RetryTask::getRetryStatus, queryVO.getRetryStatus()); | ||||
| @ -86,7 +85,7 @@ public class RetryTaskServiceImpl implements RetryTaskService { | ||||
| 
 | ||||
|         RequestDataHelper.setPartition(queryVO.getGroupName()); | ||||
| 
 | ||||
|         retryTaskLambdaQueryWrapper.select(RetryTask::getId, RetryTask::getBizNo, RetryTask::getBizId, | ||||
|         retryTaskLambdaQueryWrapper.select(RetryTask::getId, RetryTask::getBizNo, RetryTask::getIdempotentId, | ||||
|             RetryTask::getGroupName, RetryTask::getNextTriggerAt, RetryTask::getRetryCount, | ||||
|             RetryTask::getRetryStatus, RetryTask::getUpdateDt, RetryTask::getSceneName); | ||||
|         pageDTO = retryTaskMapper.selectPage(pageDTO, retryTaskLambdaQueryWrapper.orderByDesc(RetryTask::getCreateDt)); | ||||
| @ -150,25 +149,25 @@ public class RetryTaskServiceImpl implements RetryTaskService { | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public String bizIdGenerate(final GenerateRetryBizIdVO generateRetryBizIdVO) { | ||||
|         ServerNode serverNode = clientNodeAllocateHandler.getServerNode(generateRetryBizIdVO.getGroupName()); | ||||
|         Assert.notNull(serverNode, () -> new EasyRetryServerException("生成bizId失败: 不存在活跃的客户端节点")); | ||||
|     public String idempotentIdGenerate(final GenerateRetryIdempotentIdVO generateRetryIdempotentIdVO) { | ||||
|         ServerNode serverNode = clientNodeAllocateHandler.getServerNode(generateRetryIdempotentIdVO.getGroupName()); | ||||
|         Assert.notNull(serverNode, () -> new EasyRetryServerException("生成idempotentId失败: 不存在活跃的客户端节点")); | ||||
| 
 | ||||
|         // 委托客户端生成bizId | ||||
|         // 委托客户端生成idempotentId | ||||
|         String url = MessageFormat | ||||
|             .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()); | ||||
|         GenerateRetryIdempotentIdDTO generateRetryIdempotentIdDTO = new GenerateRetryIdempotentIdDTO(); | ||||
|         generateRetryIdempotentIdDTO.setGroup(generateRetryIdempotentIdVO.getGroupName()); | ||||
|         generateRetryIdempotentIdDTO.setScene(generateRetryIdempotentIdVO.getSceneName()); | ||||
|         generateRetryIdempotentIdDTO.setArgsStr(generateRetryIdempotentIdVO.getArgsStr()); | ||||
|         generateRetryIdempotentIdDTO.setExecutorName(generateRetryIdempotentIdVO.getExecutorName()); | ||||
| 
 | ||||
|         HttpEntity<GenerateRetryBizIdDTO> requestEntity = new HttpEntity<>(generateRetryBizIdDTO); | ||||
|         HttpEntity<GenerateRetryIdempotentIdDTO> requestEntity = new HttpEntity<>(generateRetryIdempotentIdDTO); | ||||
|         Result result = restTemplate.postForObject(url, requestEntity, Result.class); | ||||
| 
 | ||||
|         Assert.notNull(result, () -> new EasyRetryServerException("biz生成失败")); | ||||
|         Assert.isTrue(1 == result.getStatus(), () -> new EasyRetryServerException("biz生成失败:请确保参数与执行器名称正确")); | ||||
|         Assert.notNull(result, () -> new EasyRetryServerException("idempotentId生成失败")); | ||||
|         Assert.isTrue(1 == result.getStatus(), () -> new EasyRetryServerException("idempotentId生成失败:请确保参数与执行器名称正确")); | ||||
| 
 | ||||
|         return (String) result.getData(); | ||||
|     } | ||||
|  | ||||
| @ -53,7 +53,7 @@ public class CallbackRetryResultActor extends AbstractActor { | ||||
| 
 | ||||
|                 // 回调参数 | ||||
|                 RetryCallbackDTO retryCallbackDTO = new RetryCallbackDTO(); | ||||
|                 retryCallbackDTO.setBizId(retryTask.getBizId()); | ||||
|                 retryCallbackDTO.setIdempotentId(retryTask.getIdempotentId()); | ||||
|                 retryCallbackDTO.setRetryStatus(retryTask.getRetryStatus()); | ||||
|                 retryCallbackDTO.setArgsStr(retryTask.getArgsStr()); | ||||
|                 retryCallbackDTO.setScene(retryTask.getSceneName()); | ||||
|  | ||||
| @ -109,7 +109,7 @@ public class ExecUnitActor extends AbstractActor  { | ||||
|     private Result<DispatchRetryResultDTO> callClient(RetryTask retryTask, RetryTaskLog retryTaskLog, ServerNode serverNode) { | ||||
| 
 | ||||
|         DispatchRetryDTO dispatchRetryDTO = new DispatchRetryDTO(); | ||||
|         dispatchRetryDTO.setBizId(retryTask.getBizId()); | ||||
|         dispatchRetryDTO.setIdempotentId(retryTask.getIdempotentId()); | ||||
|         dispatchRetryDTO.setScene(retryTask.getSceneName()); | ||||
|         dispatchRetryDTO.setExecutorName(retryTask.getExecutorName()); | ||||
|         dispatchRetryDTO.setArgsStr(retryTask.getArgsStr()); | ||||
|  | ||||
| @ -83,7 +83,7 @@ public class FailureActor extends AbstractActor { | ||||
|                 // 记录重试日志 | ||||
|                 PageDTO<RetryTaskLog> retryTaskLogPageDTO = retryTaskLogMapper.selectPage(new PageDTO<>(1, 1), | ||||
|                         new LambdaQueryWrapper<RetryTaskLog>() | ||||
|                                 .eq(RetryTaskLog::getBizId, retryTask.getBizId()) | ||||
|                                 .eq(RetryTaskLog::getIdempotentId, retryTask.getIdempotentId()) | ||||
|                                 .orderByDesc(RetryTaskLog::getId)); | ||||
| 
 | ||||
|                 List<RetryTaskLog> records = retryTaskLogPageDTO.getRecords(); | ||||
|  | ||||
| @ -68,7 +68,7 @@ public class FinishActor extends AbstractActor  { | ||||
|                 // 记录重试日志 | ||||
|                 PageDTO<RetryTaskLog> retryTaskLogPageDTO = retryTaskLogMapper.selectPage(new PageDTO<>(1, 1), | ||||
|                         new LambdaQueryWrapper<RetryTaskLog>() | ||||
|                                 .eq(RetryTaskLog::getBizId, retryTask.getBizId()) | ||||
|                                 .eq(RetryTaskLog::getIdempotentId, retryTask.getIdempotentId()) | ||||
|                                 .orderByDesc(RetryTaskLog::getId)); | ||||
| 
 | ||||
|                 List<RetryTaskLog> records = retryTaskLogPageDTO.getRecords(); | ||||
|  | ||||
| @ -5,7 +5,7 @@ import com.aizuda.easy.retry.server.service.RetryTaskService; | ||||
| 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.request.BatchDeleteRetryTaskVO; | ||||
| import com.aizuda.easy.retry.server.web.model.request.GenerateRetryBizIdVO; | ||||
| import com.aizuda.easy.retry.server.web.model.request.GenerateRetryIdempotentIdVO; | ||||
| import com.aizuda.easy.retry.server.web.model.request.RetryTaskQueryVO; | ||||
| import com.aizuda.easy.retry.server.web.model.request.RetryTaskUpdateStatusRequestVO; | ||||
| import com.aizuda.easy.retry.server.web.model.request.RetryTaskSaveRequestVO; | ||||
| @ -64,9 +64,9 @@ public class RetryTaskController { | ||||
|     } | ||||
| 
 | ||||
|     @LoginRequired | ||||
|     @PostMapping("/generate/biz-id") | ||||
|     public Result<String> bizIdGenerate(@RequestBody @Validated GenerateRetryBizIdVO generateRetryBizIdVO) { | ||||
|         return new Result<>(retryTaskService.bizIdGenerate(generateRetryBizIdVO)); | ||||
|     @PostMapping("/generate/idempotent-id") | ||||
|     public Result<String> idempotentIdGenerate(@RequestBody @Validated GenerateRetryIdempotentIdVO generateRetryIdempotentIdVO) { | ||||
|         return new Result<>(retryTaskService.idempotentIdGenerate(generateRetryIdempotentIdVO)); | ||||
|     } | ||||
| 
 | ||||
|     @LoginRequired | ||||
|  | ||||
| @ -4,13 +4,13 @@ import lombok.Data; | ||||
| import org.hibernate.validator.constraints.NotBlank; | ||||
| 
 | ||||
| /** | ||||
|  * 生成bizId模型 | ||||
|  * 生成idempotentId模型 | ||||
|  * | ||||
|  * @auther www.byteblogs.com | ||||
|  * @date 2022/03/25 10:06 | ||||
|  */ | ||||
| @Data | ||||
| public class GenerateRetryBizIdVO { | ||||
| public class GenerateRetryIdempotentIdVO { | ||||
|     /** | ||||
|      * 组名称 | ||||
|      */ | ||||
| @ -12,5 +12,5 @@ public class RetryDeadLetterQueryVO extends BaseQueryVO { | ||||
|     private String groupName; | ||||
|     private String sceneName; | ||||
|     private String bizNo; | ||||
|     private String bizId; | ||||
|     private String idempotentId; | ||||
| } | ||||
|  | ||||
| @ -16,5 +16,5 @@ public class RetryTaskLogQueryVO extends BaseQueryVO { | ||||
| 
 | ||||
|     private String bizNo; | ||||
| 
 | ||||
|     private String bizId; | ||||
|     private String idempotentId; | ||||
| } | ||||
|  | ||||
| @ -17,7 +17,7 @@ public class RetryTaskQueryVO extends BaseQueryVO { | ||||
| 
 | ||||
|     private String bizNo; | ||||
| 
 | ||||
|     private String bizId; | ||||
|     private String idempotentId; | ||||
| 
 | ||||
|     private Integer retryStatus; | ||||
| } | ||||
|  | ||||
| @ -27,10 +27,10 @@ public class RetryTaskSaveRequestVO { | ||||
|     private String sceneName; | ||||
| 
 | ||||
|     /** | ||||
|      * 业务id(同一个场景下正在重试中的bizId不能重复) | ||||
|      * 幂等id(同一个场景下正在重试中的idempotentId不能重复) | ||||
|      */ | ||||
|     @NotBlank(message = "业务id不能为空") | ||||
|     private String bizId; | ||||
|     @NotBlank(message = "幂等id不能为空") | ||||
|     private String idempotentId; | ||||
| 
 | ||||
|     /** | ||||
|      * 业务编号 | ||||
|  | ||||
| @ -17,7 +17,7 @@ public class RetryDeadLetterResponseVO { | ||||
| 
 | ||||
|     private String sceneName; | ||||
| 
 | ||||
|     private String bizId; | ||||
|     private String idempotentId; | ||||
| 
 | ||||
|     private String bizNo; | ||||
| 
 | ||||
|  | ||||
| @ -17,7 +17,7 @@ public class RetryTaskLogResponseVO { | ||||
| 
 | ||||
|     private String sceneName; | ||||
| 
 | ||||
|     private String bizId; | ||||
|     private String idempotentId; | ||||
| 
 | ||||
|     private String bizNo; | ||||
| 
 | ||||
|  | ||||
| @ -18,7 +18,7 @@ public class RetryTaskResponseVO { | ||||
| 
 | ||||
|     private String sceneName; | ||||
| 
 | ||||
|     private String bizId; | ||||
|     private String idempotentId; | ||||
| 
 | ||||
|     private String bizNo; | ||||
| 
 | ||||
|  | ||||
| @ -5,7 +5,7 @@ | ||||
|     <id column="id" jdbcType="BIGINT" property="id" /> | ||||
|     <result column="group_name" jdbcType="VARCHAR" property="groupName" /> | ||||
|     <result column="scene_name" jdbcType="VARCHAR" property="sceneName" /> | ||||
|     <result column="biz_id" jdbcType="VARCHAR" property="bizId" /> | ||||
|     <result column="idempotent_id" jdbcType="VARCHAR" property="idempotentId" /> | ||||
|     <result column="biz_no" jdbcType="VARCHAR" property="bizNo" /> | ||||
|     <result column="executor_name" jdbcType="VARCHAR" property="executorName" /> | ||||
|     <result column="args_str" jdbcType="VARCHAR" property="argsStr" /> | ||||
| @ -13,17 +13,17 @@ | ||||
|     <result column="create_dt" jdbcType="TIMESTAMP" property="createDt" /> | ||||
|   </resultMap> | ||||
|   <sql id="Base_Column_List"> | ||||
|     id, group_name, scene_name, biz_id, biz_no, executor_name, args_str, ext_attrs, create_dt | ||||
|     id, group_name, scene_name, idempotent_id, biz_no, executor_name, args_str, ext_attrs, create_dt | ||||
|   </sql> | ||||
|   <insert id="insertBatch"> | ||||
|     insert into retry_dead_letter_${partition} (id, group_name, scene_name, | ||||
|                                               biz_id, biz_no, executor_name, args_str, | ||||
|     idempotent_id, biz_no, executor_name, args_str, | ||||
|                                               ext_attrs, create_dt | ||||
|     ) | ||||
|     values | ||||
|           <foreach collection="retryDeadLetters" item="retryDeadLetter" separator=","> | ||||
|             (#{retryDeadLetter.id,jdbcType=BIGINT}, #{retryDeadLetter.groupName,jdbcType=VARCHAR}, #{retryDeadLetter.sceneName,jdbcType=VARCHAR}, | ||||
|             #{retryDeadLetter.bizId,jdbcType=VARCHAR}, #{retryDeadLetter.bizNo,jdbcType=VARCHAR},  #{retryDeadLetter.executorName,jdbcType=VARCHAR}, #{retryDeadLetter.argsStr,jdbcType=VARCHAR}, | ||||
|             #{retryDeadLetter.idempotentId,jdbcType=VARCHAR}, #{retryDeadLetter.bizNo,jdbcType=VARCHAR},  #{retryDeadLetter.executorName,jdbcType=VARCHAR}, #{retryDeadLetter.argsStr,jdbcType=VARCHAR}, | ||||
|             #{retryDeadLetter.extAttrs,jdbcType=VARCHAR}, #{retryDeadLetter.createDt,jdbcType=TIMESTAMP}) | ||||
|           </foreach> | ||||
|   </insert> | ||||
|  | ||||
| @ -5,7 +5,7 @@ | ||||
|         <id column="id" jdbcType="BIGINT" property="id"/> | ||||
|         <result column="group_name" jdbcType="VARCHAR" property="groupName"/> | ||||
|         <result column="scene_name" jdbcType="VARCHAR" property="sceneName"/> | ||||
|         <result column="biz_id" jdbcType="VARCHAR" property="bizId"/> | ||||
|         <result column="idempotent_id" jdbcType="VARCHAR" property="idempotentId"/> | ||||
|         <result column="biz_no" jdbcType="VARCHAR" property="bizNo"/> | ||||
|         <result column="executor_name" jdbcType="VARCHAR" property="executorName"/> | ||||
|         <result column="args_str" jdbcType="VARCHAR" property="argsStr"/> | ||||
| @ -16,7 +16,7 @@ | ||||
|     </resultMap> | ||||
|     <sql id="Base_Column_List"> | ||||
|         id | ||||
|         , group_name, scene_name, biz_id, biz_no, executor_name, args_str, ext_attrs, retry_status, error_message, | ||||
|         , group_name, scene_name, idempotent_id, biz_no, executor_name, args_str, ext_attrs, retry_status, error_message, | ||||
|     create_dt | ||||
|     </sql> | ||||
|     <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> | ||||
| @ -28,22 +28,22 @@ | ||||
|     <select id="countTaskTotal" resultType="java.lang.Long"> | ||||
|         select count(*) | ||||
|         from ( | ||||
|                  select group_name, scene_name, biz_id from retry_task_log group by group_name, scene_name, biz_id) a | ||||
|                  select group_name, scene_name, idempotent_id from retry_task_log group by group_name, scene_name, idempotent_id) a | ||||
|     </select> | ||||
|     <select id="countTaskByRetryStatus" resultType="java.lang.Long"> | ||||
|         select count(*) | ||||
|         from ( | ||||
|                  select group_name, scene_name, biz_id | ||||
|                  select group_name, scene_name, idempotent_id | ||||
|                  from retry_task_log | ||||
|                  where retry_status = #{retryStatus} | ||||
|                  group by group_name, scene_name, biz_id) a | ||||
|                  group by group_name, scene_name, idempotent_id) a | ||||
| 
 | ||||
|     </select> | ||||
|     <select id="rankSceneQuantity" | ||||
|             resultType="com.aizuda.easy.retry.server.web.model.response.SceneQuantityRankResponseVO"> | ||||
|         select group_name, scene_name, count(*) total | ||||
|         from ( | ||||
|         select group_name, scene_name, biz_id, count(*) | ||||
|         select group_name, scene_name, idempotent_id, count(*) | ||||
|         from retry_task_log | ||||
|         <where> | ||||
|             <if test="groupName != '' and groupName != null"> | ||||
| @ -51,7 +51,7 @@ | ||||
|             </if> | ||||
|             and create_dt >= #{startTime} and create_dt <= #{endTime} | ||||
|         </where> | ||||
|         group by group_name, scene_name, biz_id) a | ||||
|         group by group_name, scene_name, idempotent_id) a | ||||
|         group by group_name, scene_name | ||||
|         order by total desc; | ||||
|     </select> | ||||
| @ -60,7 +60,7 @@ | ||||
|         select | ||||
|         distinct(create_dt), count(*) total | ||||
|         from ( | ||||
|         select group_name, scene_name, biz_id, | ||||
|         select group_name, scene_name, idempotent_id, | ||||
|         <choose> | ||||
|             <when test="type == 'day'"> | ||||
|                 DATE_FORMAT(create_dt,'%H') | ||||
| @ -90,7 +90,7 @@ | ||||
| 
 | ||||
|             and create_dt >= #{startTime} and create_dt <= #{endTime} | ||||
|         </where> | ||||
|         group by group_name, scene_name, biz_id, create_dt) a | ||||
|         group by group_name, scene_name, idempotent_id, create_dt) a | ||||
|         group by create_dt | ||||
|         order by total desc; | ||||
|     </select> | ||||
|  | ||||
| @ -5,7 +5,7 @@ | ||||
|     <id column="id" jdbcType="BIGINT" property="id" /> | ||||
|     <result column="group_name" jdbcType="VARCHAR" property="groupName" /> | ||||
|     <result column="scene_name" jdbcType="VARCHAR" property="sceneName" /> | ||||
|     <result column="biz_id" jdbcType="VARCHAR" property="bizId" /> | ||||
|     <result column="idempotent_id" jdbcType="VARCHAR" property="idempotentId" /> | ||||
|     <result column="biz_no" jdbcType="VARCHAR" property="bizNo" /> | ||||
|     <result column="executor_name" jdbcType="VARCHAR" property="executorName" /> | ||||
|     <result column="args_str" jdbcType="VARCHAR" property="argsStr" /> | ||||
| @ -17,7 +17,7 @@ | ||||
|     <result column="update_dt" jdbcType="TIMESTAMP" property="updateDt" /> | ||||
|   </resultMap> | ||||
|   <sql id="Base_Column_List"> | ||||
|     id, group_name, scene_name, biz_id, biz_no, executor_name, args_str, ext_attrs, next_trigger_at, retry_count, retry_status, | ||||
|     id, group_name, scene_name, idempotent_id, biz_no, executor_name, args_str, ext_attrs, next_trigger_at, retry_count, retry_status, | ||||
|     create_dt, update_dt | ||||
|   </sql> | ||||
|   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> | ||||
| @ -59,7 +59,7 @@ | ||||
|   <select id="selectRetryTaskByGroupIdAndSceneId" resultMap="BaseResultMap"> | ||||
|     select | ||||
|     <include refid="Base_Column_List" /> | ||||
|     from retry_task_${partition} where biz_id = #{bizId,jdbcType=VARCHAR} AND  scene_id = #{sceneId,jdbcType=VARCHAR} | ||||
|     from retry_task_${partition} where idempotent_id = #{idempotentId,jdbcType=VARCHAR} AND  scene_id = #{sceneId,jdbcType=VARCHAR} | ||||
|   </select> | ||||
|   <select id="selectRetryTaskPage" resultMap="BaseResultMap"> | ||||
|     select | ||||
|  | ||||
							
								
								
									
										2308
									
								
								example/log/sys.log
									
									
									
									
									
								
							
							
						
						
									
										2308
									
								
								example/log/sys.log
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -59,7 +59,7 @@ public class ExampleApplicationTests { | ||||
|             int finalI = i; | ||||
|             new Thread(() -> { | ||||
|                 RetryTaskDTO retryTaskDTO = new RetryTaskDTO(); | ||||
|                 retryTaskDTO.setBizId(finalI + ""); | ||||
|                 retryTaskDTO.setIdempotentId(finalI + ""); | ||||
|                 ConcurrentLinkedQueue<RetryTaskDTO> value = retryLeapArray.currentWindow().value(); | ||||
|                 value.add(retryTaskDTO); | ||||
|             }).start(); | ||||
|  | ||||
| @ -14,7 +14,7 @@ const api = { | ||||
|   retryTaskPage: '/retry-task/list', | ||||
|   retryTaskById: '/retry-task/', | ||||
|   saveRetryTask: '/retry-task', | ||||
|   bizIdGenerate: '/retry-task/generate/biz-id', | ||||
|   idempotentIdGenerate: '/retry-task/generate/idempotent-id', | ||||
|   batchUpdate: '/retry-task/batch', | ||||
|   deleteRetryTask: '/retry-task/batch', | ||||
|   updateRetryTaskStatus: '/retry-task/status', | ||||
| @ -56,9 +56,9 @@ export function batchUpdate (data) { | ||||
|   }) | ||||
| } | ||||
| 
 | ||||
| export function bizIdGenerate (data) { | ||||
| export function idempotentIdGenerate (data) { | ||||
|   return request({ | ||||
|     url: api.bizIdGenerate, | ||||
|     url: api.idempotentIdGenerate, | ||||
|     method: 'post', | ||||
|     data | ||||
|   }) | ||||
|  | ||||
| @ -10,7 +10,7 @@ | ||||
|             {{ retryDealLetterInfo.sceneName }} | ||||
|           </a-descriptions-item> | ||||
|           <a-descriptions-item label="业务id" span="2"> | ||||
|             {{ retryDealLetterInfo.bizId }} | ||||
|             {{ retryDealLetterInfo.idempotentId }} | ||||
|           </a-descriptions-item> | ||||
|           <a-descriptions-item label="业务编号"> | ||||
|             {{ retryDealLetterInfo.bizNo }} | ||||
|  | ||||
| @ -25,7 +25,7 @@ | ||||
|             </a-col> | ||||
|             <a-col :md="8" :sm="24"> | ||||
|               <a-form-item label="业务id"> | ||||
|                 <a-input v-model="queryParam.bizId" placeholder="请输入业务id" allowClear/> | ||||
|                 <a-input v-model="queryParam.idempotentId" placeholder="请输入业务id" allowClear/> | ||||
|               </a-form-item> | ||||
|             </a-col> | ||||
|           </template> | ||||
| @ -139,8 +139,8 @@ export default { | ||||
|           ellipsis: true | ||||
|         }, | ||||
|         { | ||||
|           title: '业务id', | ||||
|           dataIndex: 'bizId', | ||||
|           title: '幂等id', | ||||
|           dataIndex: 'idempotentId', | ||||
|           ellipsis: true | ||||
|         }, | ||||
|         { | ||||
|  | ||||
| @ -10,7 +10,7 @@ | ||||
|             {{ retryInfo.sceneName }} | ||||
|           </a-descriptions-item> | ||||
|           <a-descriptions-item label="业务id" span="2"> | ||||
|             {{ retryInfo.bizId }} | ||||
|             {{ retryInfo.idempotentId }} | ||||
|           </a-descriptions-item> | ||||
|           <a-descriptions-item label="业务编号"> | ||||
|             {{ retryInfo.bizNo }} | ||||
|  | ||||
| @ -25,7 +25,7 @@ | ||||
|             </a-col> | ||||
|             <a-col :md="8" :sm="24"> | ||||
|               <a-form-item label="业务id"> | ||||
|                 <a-input v-model="queryParam.bizId" placeholder="请输入业务id" allowClear/> | ||||
|                 <a-input v-model="queryParam.idempotentId" placeholder="请输入业务id" allowClear/> | ||||
|               </a-form-item> | ||||
|             </a-col> | ||||
|           </template> | ||||
| @ -115,8 +115,8 @@ export default { | ||||
|           ellipsis: true | ||||
|         }, | ||||
|         { | ||||
|           title: '业务id', | ||||
|           dataIndex: 'bizId' | ||||
|           title: '幂等id', | ||||
|           dataIndex: 'idempotentId' | ||||
|         }, | ||||
|         { | ||||
|           title: '业务编号', | ||||
|  | ||||
| @ -10,7 +10,7 @@ | ||||
|             {{ retryTaskInfo.sceneName }} | ||||
|           </a-descriptions-item> | ||||
|           <a-descriptions-item label="业务id" span="2"> | ||||
|             {{ retryTaskInfo.bizId }} | ||||
|             {{ retryTaskInfo.idempotentId }} | ||||
|           </a-descriptions-item> | ||||
|           <a-descriptions-item label="业务编号"> | ||||
|             {{ retryTaskInfo.bizNo }} | ||||
|  | ||||
| @ -40,7 +40,7 @@ | ||||
|             </a-col> | ||||
|             <a-col :md="8" :sm="24"> | ||||
|               <a-form-item label="业务id"> | ||||
|                 <a-input v-model="queryParam.bizId" placeholder="请输入业务id" allowClear /> | ||||
|                 <a-input v-model="queryParam.idempotentId" placeholder="请输入业务id" allowClear /> | ||||
|               </a-form-item> | ||||
|             </a-col> | ||||
|           </template> | ||||
| @ -156,8 +156,8 @@ export default { | ||||
|           dataIndex: 'sceneName' | ||||
|         }, | ||||
|         { | ||||
|           title: '业务id', | ||||
|           dataIndex: 'bizId' | ||||
|           title: '幂等id', | ||||
|           dataIndex: 'idempotentId' | ||||
|         }, | ||||
|         { | ||||
|           title: '业务编号', | ||||
|  | ||||
| @ -29,15 +29,15 @@ | ||||
|         </a-form-item> | ||||
|         <a-form-item label="重试ID"> | ||||
|           <a-input | ||||
|             v-decorator="['bizId', { rules: [{ required: true, message: '请输入重试ID' }] }]" | ||||
|             name="bizId" | ||||
|             v-decorator="['idempotentId', { rules: [{ required: true, message: '请输入重试ID' }] }]" | ||||
|             name="idempotentId" | ||||
|             placeholder="请输入业务编号" | ||||
|           > | ||||
|             <a-tooltip slot="suffix" title="同一个场景下正在重试中的重试ID不能重复,若重复的重试ID在上报时会被幂等处理"> | ||||
|               <a-icon type="info-circle" style="color: rgba(0, 0, 0, 0.45)" /> | ||||
|             </a-tooltip> | ||||
|           </a-input> | ||||
|           <a-button type="primary" style="position: absolute; margin: 3px 10px" @click="bizIdGenerate"> 生成 </a-button> | ||||
|           <a-button type="primary" style="position: absolute; margin: 3px 10px" @click="idempotentIdGenerate"> 生成 </a-button> | ||||
|         </a-form-item> | ||||
|         <a-form-item label="业务编号"> | ||||
|           <a-input | ||||
| @ -71,7 +71,7 @@ | ||||
| </template> | ||||
| 
 | ||||
| <script> | ||||
| import { getAllGroupNameList, getSceneList, saveRetryTask, bizIdGenerate } from '@/api/manage' | ||||
| import { getAllGroupNameList, getSceneList, saveRetryTask, idempotentIdGenerate } from '@/api/manage' | ||||
| 
 | ||||
| export default { | ||||
|   name: 'SavRetryTask', | ||||
| @ -121,15 +121,15 @@ export default { | ||||
|         this.groupNameList = res.data | ||||
|       }) | ||||
|     }, | ||||
|     bizIdGenerate () { | ||||
|     idempotentIdGenerate () { | ||||
|       const groupName = this.form.getFieldValue('groupName') | ||||
|       const sceneName = this.form.getFieldValue('sceneName') | ||||
|       const executorName = this.form.getFieldValue('executorName') | ||||
|       const argsStr = this.form.getFieldValue('argsStr') | ||||
| 
 | ||||
|       bizIdGenerate({ groupName, sceneName, executorName, argsStr }).then(res => { | ||||
|       idempotentIdGenerate({ groupName, sceneName, executorName, argsStr }).then(res => { | ||||
|         this.form.setFieldsValue({ | ||||
|           'bizId': res.data | ||||
|           'idempotentId': res.data | ||||
|         }) | ||||
|       }) | ||||
|     } | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user