window部署wordpress,网站换域名了怎么办seo,无锡百度推广平台,台州市建设施工图审图网站提示#xff1a;文章写完后#xff0c;目录可以自动生成#xff0c;如何生成可参考右边的帮助文档 文章目录 前言一、引入依赖二、主启动类上加EnableRetry三、Server层注意 四、失败后回调方法总结 前言
提示#xff1a;SpringBoot项目为例 原文链接#xff1a;https://… 提示文章写完后目录可以自动生成如何生成可参考右边的帮助文档 文章目录 前言一、引入依赖二、主启动类上加EnableRetry三、Server层注意 四、失败后回调方法总结 前言
提示SpringBoot项目为例 原文链接https://blog.csdn.net/imVainiycos/article/details/123106451 一、引入依赖
dependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.springframework.retry/groupIdartifactIdspring-retry/artifactId/dependencydependencygroupIdorg.aspectj/groupIdartifactIdaspectjweaver/artifactId/dependency
/dependencies二、主启动类上加EnableRetry EnableRetry
SpringBootApplication
public class KafkaApiApplication {public static void main(String[] args) {SpringApplication.run(KafkaApiApplication.class, args);}
}三、Server层
注意
定义Controller层下层需要进行throws抛出异常或者我们进行trycatch进行异常捕捉 否则重试机制将会不生效。
Retryable注解中参数说明 value哪种异常情况下需要重试. maxAttempts最大重试次数 delay重试延迟时间毫秒计数 multiplier下次执行时间 上次时间 * 倍数。 /*** 调用第三方接口方法位置添加重试注解相关参数配置。*/Retryable(value Exception.class,maxAttempts 3,backoff Backoff(delay 5 * 60 * 1000,multiplier 2))Overridepublic void updateBatchOld(ListString snList) {if (CollectionUtils.isNotEmpty(snList)) {ListDeviceDetailLowFrequency ktdData null;try {ktdData inverterKtdFeign.getKtdData(snList);} catch (Exception e) {log.info(调用低频接口失败 snList);throw new MyException(ResultCodeEnum.FEIGN_SERVICE_ERROR);}ktdData.forEach(a - a.setUpdateTime(new Date()));this.updateBatchById(ktdData);}}四、失败后回调方法 若在最大重试次数下还是没有成功则回调方法编写。 Service实现类中代码如下 /*** 使用 Recover注解*/Recoverpublic void recover(Exception e){//记日志到数据库 或 打印日志.}引用原文链接点击跳转
总结 提示好小子你又在学习打死你。