本文整理汇总了Java中org.springframework.retry.policy.SimpleRetryPolicy.setMaxAttempts方法的典型用法代码示例。如果您正苦于以下问题:Java SimpleRetryPolicy.setMaxAttempts方法的具体用法?Java SimpleRetryPolicy.setMaxAttempts怎么用?Java SimpleRetryPolicy.setMaxAttempts使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.retry.policy.SimpleRetryPolicy
的用法示例。
在下文中一共展示了SimpleRetryPolicy.setMaxAttempts方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertProcessEnded
import org.springframework.retry.policy.SimpleRetryPolicy; //导入方法依赖的package包/类
private void assertProcessEnded(final ProcessInstance pi) {
// fetch active executions
RetryTemplate retryTemplate = new RetryTemplate();
final SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy();
retryPolicy.setMaxAttempts(5);
retryTemplate.setRetryPolicy(retryPolicy);
FixedBackOffPolicy backOffPolicy = new FixedBackOffPolicy();
retryTemplate.setBackOffPolicy(backOffPolicy);
retryTemplate.execute(new RetryCallback<Void, RuntimeException>() {
@Override
public Void doWithRetry(RetryContext retryContext) throws RuntimeException {
List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().list();
int processCount = processInstances.size();
LOGGER.info("waiting for process to end (Still {} process running).", processCount);
if (processCount > 0) {
for (ProcessInstance processInstance : processInstances) {
LOGGER.info("Process info: {} ", dumpprocessInstance(processInstance));
}
throw new IllegalStateException("Some process still running. Left :" + processCount);
}
return null;
}
});
}
示例2: arkClientRetryTemplate
import org.springframework.retry.policy.SimpleRetryPolicy; //导入方法依赖的package包/类
@Bean
public RetryTemplate arkClientRetryTemplate() {
RetryTemplate retryTemplate = new RetryTemplate();
Map<Class<? extends Throwable>, Boolean> includeExceptions = new HashMap<>();
includeExceptions.put(RuntimeException.class, true);
ExponentialBackOffPolicy exponentialBackOffPolicy = new ExponentialBackOffPolicy();
exponentialBackOffPolicy.setInitialInterval(10);
exponentialBackOffPolicy.setMultiplier(2.0);
retryTemplate.setBackOffPolicy(exponentialBackOffPolicy);
SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(10, includeExceptions);
retryPolicy.setMaxAttempts(10);
retryTemplate.setRetryPolicy(retryPolicy);
return retryTemplate;
}
示例3: arkClientRetryTemplate
import org.springframework.retry.policy.SimpleRetryPolicy; //导入方法依赖的package包/类
@Bean
public RetryTemplate arkClientRetryTemplate() {
RetryTemplate retryTemplate = new RetryTemplate();
Map<Class<? extends Throwable>, Boolean> includeExceptions = new HashMap<>();
includeExceptions.put(RuntimeException.class, true);
ExponentialBackOffPolicy exponentialBackOffPolicy = new ExponentialBackOffPolicy();
exponentialBackOffPolicy.setInitialInterval(100);
exponentialBackOffPolicy.setMultiplier(2.0);
retryTemplate.setBackOffPolicy(exponentialBackOffPolicy);
SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(5, includeExceptions);
retryPolicy.setMaxAttempts(5);
retryTemplate.setRetryPolicy(retryPolicy);
return retryTemplate;
}
示例4: createRetryPolicy
import org.springframework.retry.policy.SimpleRetryPolicy; //导入方法依赖的package包/类
private static RetryPolicy createRetryPolicy() {
final SimpleRetryPolicy simpleRetryPolicy = new SimpleRetryPolicy();
simpleRetryPolicy.setMaxAttempts(5);
final Map<Class<? extends Throwable>, RetryPolicy> policyMap = new HashMap<>();
policyMap.put(TempoApiException.class, new NeverRetryPolicy());
policyMap.put(FeignException.class, new NeverRetryPolicy());
policyMap.put(IOException.class, simpleRetryPolicy);
policyMap.put(RetryableException.class, simpleRetryPolicy);
final ExceptionClassifierRetryPolicy retryPolicy = new ExceptionClassifierRetryPolicy();
retryPolicy.setPolicyMap(policyMap);
return simpleRetryPolicy;
}
示例5: afterPropertiesSet
import org.springframework.retry.policy.SimpleRetryPolicy; //导入方法依赖的package包/类
@Override
public void afterPropertiesSet() throws Exception {
if (this.metadataRetryOperations == null) {
RetryTemplate retryTemplate = new RetryTemplate();
SimpleRetryPolicy simpleRetryPolicy = new SimpleRetryPolicy();
simpleRetryPolicy.setMaxAttempts(10);
retryTemplate.setRetryPolicy(simpleRetryPolicy);
ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
backOffPolicy.setInitialInterval(100);
backOffPolicy.setMultiplier(2);
backOffPolicy.setMaxInterval(1000);
retryTemplate.setBackOffPolicy(backOffPolicy);
this.metadataRetryOperations = retryTemplate;
}
}
示例6: getRetryTemplate
import org.springframework.retry.policy.SimpleRetryPolicy; //导入方法依赖的package包/类
/**
* get a spring customized retry template
*
* @param retryAttempts
* @return a customized retry template
*/
private static RetryTemplate getRetryTemplate(int retryAttempts) {
// we set the retry time out
SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy();
retryPolicy.setMaxAttempts(retryAttempts);
// our retry service
RetryTemplate retryTemplate = new RetryTemplate();
retryTemplate.setRetryPolicy(retryPolicy);
return retryTemplate;
}
示例7: execute
import org.springframework.retry.policy.SimpleRetryPolicy; //导入方法依赖的package包/类
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
RetryTemplate retryTemplate = new RetryTemplate();
SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy();
retryPolicy.setMaxAttempts(3);
retryTemplate.setRetryPolicy(retryPolicy);
// HINT: 재시도 정책을 지정해서 3번까지 재시도를 수행합니다.
//
List<Discount> discounts = retryTemplate.execute(new RetryCallback<List<Discount>>() {
@Override
public List<Discount> doWithRetry(RetryContext context) throws Exception {
return discountService.getDiscounts();
}
});
discountsHolder.setDiscounts(discounts);
return RepeatStatus.FINISHED;
}
示例8: createRetryTemplate
import org.springframework.retry.policy.SimpleRetryPolicy; //导入方法依赖的package包/类
private RetryTemplate createRetryTemplate(RabbitProperties.Retry properties) {
RetryTemplate template = new RetryTemplate();
SimpleRetryPolicy policy = new SimpleRetryPolicy();
policy.setMaxAttempts(properties.getMaxAttempts());
template.setRetryPolicy(policy);
ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
backOffPolicy.setInitialInterval(properties.getInitialInterval());
backOffPolicy.setMultiplier(properties.getMultiplier());
backOffPolicy.setMaxInterval(properties.getMaxInterval());
template.setBackOffPolicy(backOffPolicy);
return template;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:RabbitAutoConfiguration.java
示例9: buildRetryTemplate
import org.springframework.retry.policy.SimpleRetryPolicy; //导入方法依赖的package包/类
/**
* Create and configure a retry template.
*
* @param properties The properties.
* @return The retry template
*/
public RetryTemplate buildRetryTemplate(ConsumerProperties properties) {
RetryTemplate template = new RetryTemplate();
SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy();
retryPolicy.setMaxAttempts(properties.getMaxAttempts());
ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
backOffPolicy.setInitialInterval(properties.getBackOffInitialInterval());
backOffPolicy.setMultiplier(properties.getBackOffMultiplier());
backOffPolicy.setMaxInterval(properties.getBackOffMaxInterval());
template.setRetryPolicy(retryPolicy);
template.setBackOffPolicy(backOffPolicy);
return template;
}
示例10: retryAdvice
import org.springframework.retry.policy.SimpleRetryPolicy; //导入方法依赖的package包/类
@Bean
public RetryOperationsInterceptor retryAdvice() {
SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy();
retryPolicy.setMaxAttempts(2);
RetryTemplate retryTemplate = new RetryTemplate();
retryTemplate.setRetryPolicy(retryPolicy);
RetryOperationsInterceptor interceptor = new RetryOperationsInterceptor();
interceptor.setRetryOperations(retryTemplate);
return interceptor;
}
示例11: getSimpleRetryPolicy
import org.springframework.retry.policy.SimpleRetryPolicy; //导入方法依赖的package包/类
private SimpleRetryPolicy getSimpleRetryPolicy() {
SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy();
retryPolicy.setMaxAttempts(waitForAuthorElbMaxAttempts);
return retryPolicy;
}
示例12: simpleRetryPolicy
import org.springframework.retry.policy.SimpleRetryPolicy; //导入方法依赖的package包/类
public SimpleRetryPolicy simpleRetryPolicy(int maxAttempts) {
SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy();
retryPolicy.setMaxAttempts(maxAttempts);
return retryPolicy;
}