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 ...
随机推荐
- hdu 1856 More is better (并查集)
More is better Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 327680/102400 K (Java/Others) ...
- 【题解】【CF Round #278】Tourists
圆方树第二题…… 图中询问的是指定两点之间简单路径上点的最小权值.若我们建出圆方树,圆点的权值为自身权值,方点的权值为所连接的圆点的权值最小值(即点双连通分量中的最小权值).我们可以发现其实就是这两点 ...
- [CF1065A]Vasya and Chocolate
题目大意:有$s$元,一个物品$c$元,每买$a$个就送$b$个,问一共可以买多少. 题解:全部买好,最后看可以送多少(其实是因为我这道题交错了,无聊才做的) 卡点:无 C++ Code: #incl ...
- Any gotchas at all with converting from MyISAM to InnoDB?
Q: I'm ready to move from MyISAM to InnoDB but wanted to know if there was a full list of things to ...
- Lesson 3
1.关于面向对象的三个重要属性 Encapsulation(封装):无法直接访问类的成员变量,而是通过一些get set方法,间接访问数据域: Polymorphism(多态):静态绑定,动态绑定, ...
- NYOJ 20 吝啬的国度 (深搜)
题目链接 描述 在一个吝啬的国度里有N个城市,这N个城市间只有N-1条路把这个N个城市连接起来.现在,Tom在第S号城市,他有张该国地图,他想知道如果自己要去参观第T号城市,必须经过的前一个城市是几号 ...
- [bzoj1823][JSOI2010]满汉全席——2-SAT
题目大意 题目又丑又长我就不贴了,说一下大意,有n种菜,m个评委,每一个评委又有两种喜好,每种菜有满汉两种做法,只能选一种.判断是否存在一种方案使得所有评委至少喜欢一种菜品.输入包含多组数据. 题解 ...
- bzoj 1500 修改区间 splay
内个我也不知道哪儿不对,TLE了,说说思路吧 其实思路也没什么说的,就是裸的splay,对于最后一个操作 我们记下每个区间的最长前缀,最长后缀,那么最长子序列就是 前缀,后缀,左子树的后缀+右子树的前 ...
- bzoj 1051 tarjan强连通分量
2013-11-16 11:39 原题传送门http://www.lydsy.com/JudgeOnline/problem.php?id=1051 强连通分量,缩完点之后看出度为0的强连通分量有几个 ...
- MongoDB 聚合(管道与表达式)
MongoDB中聚合(aggregate)主要用于处理数据(诸如统计平均值,求和等),并返回计算后的数据结果.有点类似sql语句中的 count(*). aggregate() 方法 MongoDB中 ...