# loop-cure **Repository Path**: syuson/loop-cure ## Basic Information - **Project Name**: loop-cure - **Description**: 对于非数据原因导致失败的业务建立重试补偿机制。具体业务场景比如:微信支付通知,第三方通知失败等 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 2 - **Created**: 2020-08-22 - **Last Updated**: 2022-01-10 ## Categories & Tags **Categories**: Uncategorized **Tags**: 重试, 循环, 补偿 ## README # loop-cure #### 介绍 对于非数据原因导致失败的业务建立重试补偿机制。具体业务场景比如:微信支付通知,第三方通知失败等 #### 使用说明 1、引入依赖(下载项目,生成本地jar包,推送到本地maven) com.syu loop-cure 1.0-SNAPSHOT 2、建表,[ddl](https://gitee.com/syuson/loop-cure/blob/master/src/main/resources/tool_cure_compensator.sql) 3、使用@CompensatorLog注解 maxRetryTimes:补偿最大尝试次数(默认2次); waitSeconds:重试时间间隔(秒,默认60),每次间隔相同,填写单一数字,譬如:60;每次间隔不同,填写多个数字且使用逗号连接,譬如:60,300; 需要重试,通过 throw new CompensatorBusinessException 触发 @CompensatorLog(maxRetryTimes=5,waitSeconds="10") public void test(String userId, String merCode) { int randomInt = (int) (Math.random()*(99)+1); if ( randomInt < RANDOM_TOP) { throw new CompensatorBusinessException(String.format("随机数:[%s]小于50,需要重试补偿",randomInt)); } } 4、可选配置 loop-cure: task-fixedRate: 12000 #任务间隔时间(毫秒),默认20秒即 20000 timeout-max: 1200 #历史任务最大执行时间(秒),默认30分钟,即1800