当前位置: 首页>>代码示例>>Java>>正文


Java SimpleRetryPolicy.setMaxAttempts方法代码示例

本文整理汇总了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;
        }
    });
}
 
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:25,代码来源:ErrorCatchingTest.java

示例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;
}
 
开发者ID:ark-aces,项目名称:aces-backend,代码行数:19,代码来源:EthBridgeConfig.java

示例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;
}
 
开发者ID:bradyo,项目名称:ark-java-smart-bridge-listener,代码行数:19,代码来源:EthBridgeConfig.java

示例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;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:16,代码来源:TempoApiConfiguration.java

示例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;
	}
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-kafka,代码行数:18,代码来源:KafkaTopicProvisioner.java

示例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;
}
 
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:17,代码来源:CfAdapterImpl.java

示例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;
}
 
开发者ID:debop,项目名称:spring-batch-experiments,代码行数:21,代码来源:DiscountsWithRetryTemplateTasklet.java

示例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;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream,代码行数:19,代码来源:AbstractBinder.java

示例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;
}
 
开发者ID:debop,项目名称:spring-batch-experiments,代码行数:15,代码来源:RetryTemplateConfiguration.java

示例11: getSimpleRetryPolicy

import org.springframework.retry.policy.SimpleRetryPolicy; //导入方法依赖的package包/类
private SimpleRetryPolicy getSimpleRetryPolicy() {
    SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy();
    retryPolicy.setMaxAttempts(waitForAuthorElbMaxAttempts);
    return retryPolicy;
}
 
开发者ID:shinesolutions,项目名称:aem-orchestrator,代码行数:6,代码来源:ResourceReadyChecker.java

示例12: simpleRetryPolicy

import org.springframework.retry.policy.SimpleRetryPolicy; //导入方法依赖的package包/类
public SimpleRetryPolicy simpleRetryPolicy(int maxAttempts) {
	SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy();
	retryPolicy.setMaxAttempts(maxAttempts);
	return retryPolicy;
}
 
开发者ID:debop,项目名称:spring-batch-experiments,代码行数:6,代码来源:RetryBehaviorConfiguration.java


注:本文中的org.springframework.retry.policy.SimpleRetryPolicy.setMaxAttempts方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。