Retrying Operations using Spring's RetryTemplate
If your application is using Spring then it is easier to use the Spring Framework's RetryTemplate.
The example below shows how you can use a RetryTemplate to lookup a remote object. If the remote call fails, it will be retried five times with exponential backoff.
// import the necessary classesimport org.springframework.batch.retry.RetryCallback;import org.springframework.batch.retry.RetryContext;import org.springframework.batch.retry.backoff.ExponentialBackOffPolicy;import org.springframework.batch.retry.policy.SimpleRetryPolicy;import org.springframework.batch.retry.support.RetryTemplate;...// create the retry templatefinal RetryTemplate template = new RetryTemplate();template.setRetryPolicy(new SimpleRetryPolicy(5));final ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();backOffPolicy.setInitialInterval(1000L);template.setBackOffPolicy(backOffPolicy);// execute the operation using the retry templatetemplate.execute(new RetryCallback<Remote>() { @Override public Remote doWithRetry(final RetryContext context) throws Exception { }}); |
Retrying Operations using Spring's RetryTemplate的更多相关文章
- Java Retry implement
There are many cases in which you may wish to retry an operation a certain number of times. Examples ...
- spring boot application.properties 属性详解
2019年3月21日17:09:59 英文原版: https://docs.spring.io/spring-boot/docs/current/reference/html/common-appli ...
- spring boot application.properties详解
附上最新文档地址:https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-propertie ...
- Spring Cloud Summary
Spring Cloud Summary https://cloud.spring.io/spring-cloud-static/Finchley.RC1/single/spring-cloud.ht ...
- 【spring boot】application.properties官方完整文档
官方地址: https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/ 进入搜索: Appendice ...
- spring boot application 配置详情
# =================================================================== # COMMON SPRING BOOT PROPERTIE ...
- CRUD using Spring MVC 4.0 RESTful Web Services and AngularJS
国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...
- Spring, Hibernate and Oracle Stored Procedures
一篇英文博文,写的是利用hibernate处理存储过程中的游标等等: Motivation: While there are a few resources available online for ...
- SpringBoot标准Properties
# =================================================================== # COMMON SPRING BOOT PROPERTIE ...
随机推荐
- 【NOIP模拟赛】天神下凡 动态开点线段树
这些圆一定是在同一水平面上的,由于他们没有相交,因此我们发现他们每个人与外界关系可以分为,1.存在并圈圈 2.存在圈圈并被割,因此我们把所有的圆都加1,把被割的在加1,就可以啦,因此我们开一个线段树, ...
- js 日期获去及格式化
原文地址:http://www.cnblogs.com/qinpengming/archive/2012/12/03/2800002.html Js获取当前日期时间及格式化操作 var myDate ...
- vue文件使用stylus报错问题
先npm install stylus --save然后安装你少的page.json中依赖:npm install stylus-loader css-loader style-loader --sa ...
- postfix导致maillog填满磁盘空间的巨坑!
双休日回家pull在公司修改的代码...于是菜鸟的linux探索之路开始了 1.df -f发现磁盘又占满了(之前是node的error) 2.发现maillog整整10个G,无数条(Jul 7 04: ...
- idea真不习惯啊
http://blog.csdn.net/z69183787/article/details/41416189
- bzoj 1041 数学推理
原题传送门http://www.lydsy.com/JudgeOnline/problem.php?id=1041 我们只需要求第一象限内(不包括坐标轴)的点数然后ans=ans*4+4就好了 首先我 ...
- Red Hat EX413 通过笔记
最近通过了EX413考试,在这里记录一下- EX413是Red Hat RH413对应的考试,RH413主要涉及Linux主机加固内容.考试大概18题的样子,给两台虚拟机,然后按照各个题目要求进行安全 ...
- python 实现定时循环触发某个方法
直接贴上代码 import threading def sayhello(): print "hello world" global t #Notice: use global v ...
- urlparse获取url后面的参数
copyfrom: http://www.cnpythoner.com/post/263.html 如果给定你一个URL,比如: http://url/api?param=2¶m2=4 ...
- container_of分析--可用good【转】
转自:http://blog.csdn.net/tigerjibo/article/details/8299589 版权声明:本文为博主原创文章,未经博主允许不得转载. 1.container_of宏 ...