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 ...
随机推荐
- [BZOJ5417] [NOI2018]你的名字
Description 小A 被选为了ION2018 的出题人,他精心准备了一道质量十分高的题目,且已经把除了题目命名以外的工作都做好了. 由于ION 已经举办了很多届,所以在题目命名上也是有规定的, ...
- [洛谷P1951]收费站_NOI导刊2009提高(2)
题目大意:有一张$n$个点$m$条边的图,每个点有一个权值$w_i$,有边权,询问从$S$到$T$的路径中,边权和小于$s$,且$\max\limits_{路径经过k}\{w_i\}$最小,输出这个最 ...
- pb_ds
#include<ext/pb_ds/priority_queue.hpp>#define ll long long#define pa pair<ll,int>using n ...
- noip 2011观光公交
P1315 观光公交 95通过 244提交 题目提供者该用户不存在 标签贪心递推2011NOIp提高组 难度提高+/省选- 提交该题 讨论 题解 记录 题目描述 风景迷人的小城Y 市,拥有n 个美 ...
- Linux内存 性能调优
内存是影响Linux性能的主要因素之一,内存资源的充足与否直接影响应用系统的使用性能. free命令:监控Linux内存使用状况. 由上图可知,空闲内存是free+buffers+cached=155 ...
- php SPL四种常用的数据结构
1.栈[先进后出] $stack = new SplStack(); $stack->push('data1'); $stack->push('data2'); $stack->pu ...
- wait , notify 模拟 Queue
package com.itdoc.multi.sync009; import java.util.LinkedList; import java.util.concurrent.TimeUnit; ...
- js获取当前url地址参数中文乱码问题
网上看了一些关于此问题的文章,都说的不清不楚,有些更是乱七八糟,完全没法看,故此找了一篇能用的,借鉴作为笔记. //首先获取到当前页面的地址栏信息 var url = window.location. ...
- HDU 2554 N对数的排列问题 ( 数学 )
题目链接 Problem Description 有N对双胞胎,他们的年龄分别是1,2,3,--,N岁,他们手拉手排成一队到野外去玩,要经过一根独木桥,为了安全起见,要求年龄大的和年龄小的排在一起,好 ...
- 使用MapReduce将HDFS数据导入到HBase(三)
使用MapReduce生成HFile文件,通过BulkLoader方式(跳过WAL验证)批量加载到HBase表中 package com.mengyao.bigdata.hbase; import j ...