1 Star 0 Fork 2

yuedaotian/loop-cure

forked from syu/loop-cure 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

loop-cure

介绍

对于非数据原因导致失败的业务建立重试补偿机制。具体业务场景比如:微信支付通知,第三方通知失败等

使用说明

1、引入依赖(下载项目,生成本地jar包,推送到本地maven)

	<dependency>
		<groupId>com.syu</groupId>
		<artifactId>loop-cure</artifactId>
		<version>1.0-SNAPSHOT</version>
	</dependency>

2、建表,ddl

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

空文件

简介

对于非数据原因导致失败的业务建立重试补偿机制。具体业务场景比如:微信支付通知,第三方通知失败等 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yuedaotian/loop-cure.git
git@gitee.com:yuedaotian/loop-cure.git
yuedaotian
loop-cure
loop-cure
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891