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


Java RetryTemplate.setBackOffPolicy方法代码示例

本文整理汇总了Java中org.springframework.retry.support.RetryTemplate.setBackOffPolicy方法的典型用法代码示例。如果您正苦于以下问题:Java RetryTemplate.setBackOffPolicy方法的具体用法?Java RetryTemplate.setBackOffPolicy怎么用?Java RetryTemplate.setBackOffPolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.retry.support.RetryTemplate的用法示例。


在下文中一共展示了RetryTemplate.setBackOffPolicy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: assertProcessEnded

import org.springframework.retry.support.RetryTemplate; //导入方法依赖的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: retryTemplate

import org.springframework.retry.support.RetryTemplate; //导入方法依赖的package包/类
/**
 * Returns a retry template that always retries.  Starts with a second interval between retries and doubles that interval up
 * to a minute for each retry.
 *
 * @return A retry template.
 */
protected RetryTemplate retryTemplate() {
	RetryTemplate retry = new RetryTemplate();

	Map<Class<? extends Throwable>, Boolean> stopExceptions =
			Collections.singletonMap(InterruptedException.class, Boolean.FALSE);
	SimpleRetryPolicy retryPolicy =
			new SimpleRetryPolicy(Integer.MAX_VALUE, stopExceptions, true, true);

	retry.setRetryPolicy(retryPolicy);

	ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
	backOffPolicy.setInitialInterval(1000);
	backOffPolicy.setMultiplier(2.0);
	backOffPolicy.setMaxInterval(60000);
	retry.setBackOffPolicy(backOffPolicy);

	return retry;
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:25,代码来源:AnyOrderActionService.java

示例3: arkClientRetryTemplate

import org.springframework.retry.support.RetryTemplate; //导入方法依赖的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

示例4: arkClientRetryTemplate

import org.springframework.retry.support.RetryTemplate; //导入方法依赖的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

示例5: tempoApiRetryPolicy

import org.springframework.retry.support.RetryTemplate; //导入方法依赖的package包/类
@Bean
@Qualifier("tempo")
public RetryOperations tempoApiRetryPolicy() {
    final RetryPolicy retryPolicy = createRetryPolicy();

    final ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
    backOffPolicy.setInitialInterval(2000);
    backOffPolicy.setMultiplier(3);

    final RetryTemplate retryTemplate = new RetryTemplate();
    retryTemplate.setRetryPolicy(retryPolicy);
    retryTemplate.setBackOffPolicy(backOffPolicy);
    retryTemplate.setThrowLastExceptionOnExhausted(true);

    return retryTemplate;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:17,代码来源:TempoApiConfiguration.java

示例6: afterPropertiesSet

import org.springframework.retry.support.RetryTemplate; //导入方法依赖的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

示例7: getRetryTemplate

import org.springframework.retry.support.RetryTemplate; //导入方法依赖的package包/类
/**
 * Configure and return the retry template.
 */
public RetryTemplate getRetryTemplate(){
    //Create RetryTemplate
    final RetryTemplate retryTemplate = new RetryTemplate();
    
    //Create Fixed back policy
    final FixedBackOffPolicy fixedBackOffPolicy = new FixedBackOffPolicy();
    
    //Set backOffPeriod
    fixedBackOffPolicy.setBackOffPeriod(Long.valueOf(backOffPeriod));
    
    //Set the backoff policy
    retryTemplate.setBackOffPolicy(fixedBackOffPolicy);

    //Create Simple Retry Policy
    final CmsRetryPolicy retryPolicy = new CmsRetryPolicy(Integer.valueOf(maxAttempts), Collections
            .<Class<? extends Throwable>, Boolean> singletonMap(RestClientException.class, true), false);

    //Set retry policy
    retryTemplate.setRetryPolicy(retryPolicy);
    
    //Return the RetryTemplate
    return retryTemplate;
}
 
开发者ID:sastix,项目名称:cms,代码行数:27,代码来源:RestTemplateConfiguration.java

示例8: getWithRetry

import org.springframework.retry.support.RetryTemplate; //导入方法依赖的package包/类
public ExitStatus getWithRetry(RetryCallback<ExitStatus, Exception> callback) {
	RetryTemplate retryTemplate = new RetryTemplate();
	FixedBackOffPolicy backOffPolicy = new FixedBackOffPolicy();
	Map<Class<? extends Throwable>,Boolean> retryableExceptions = new HashMap<Class<? extends Throwable>,Boolean>();
	retryableExceptions.put(ClientProtocolException.class, Boolean.TRUE);
	retryableExceptions.put(IOException.class, Boolean.TRUE);

	SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(retryAttempts, retryableExceptions);
	backOffPolicy.setBackOffPeriod(backoffPeriod);

	retryTemplate.setListeners(retryListeners);
	retryTemplate.setBackOffPolicy(backOffPolicy);
	retryTemplate.setRetryPolicy(retryPolicy);

	try {
		return retryTemplate.execute(callback);
	} catch (Exception e) {
		logger.error("Retry processing failed " + e.getMessage());
		return ExitStatus.FAILED;
	}
}
 
开发者ID:RBGKew,项目名称:powop,代码行数:22,代码来源:GetResourceClient.java

示例9: getRetryTemplate

import org.springframework.retry.support.RetryTemplate; //导入方法依赖的package包/类
/**
 * get a spring customized retry template
 * 
 * @param timeoutInSec
 * @return a customized retry template
 */
private static RetryTemplate getRetryTemplate(Integer timeoutInSec) {
	// we set the retry time out
	TimeoutRetryPolicy retryPolicy = new TimeoutRetryPolicy();
	retryPolicy.setTimeout(timeoutInSec * 1000 * 60);

	// we set the back off period to 60s
	FixedBackOffPolicy backOffPolicy = new FixedBackOffPolicy();
	backOffPolicy.setBackOffPeriod(60000);

	// our retry service
	RetryTemplate retryTemplate = new RetryTemplate();
	retryTemplate.setRetryPolicy(retryPolicy);
	retryTemplate.setBackOffPolicy(backOffPolicy);
	return retryTemplate;
}
 
开发者ID:orange-cloudfoundry,项目名称:elpaaso-core,代码行数:22,代码来源:EnvironmentStoriesSteps.java

示例10: getConsul

import org.springframework.retry.support.RetryTemplate; //导入方法依赖的package包/类
private Consul getConsul() {
    // test that the client is active - the purpose of this test is to make sure that the instance of consul in the
    // cluster is alive, is it's not we'll create a new one before giving up. The assumption is that the hostname of
    // consul is really a consul service that hides multiple instances of consul servers.
    RetryTemplate retryTemplate = new RetryTemplate();
    retryTemplate.setBackOffPolicy(new FixedBackOffPolicy());
    TimeoutRetryPolicy retryPolicy = new TimeoutRetryPolicy();
    retryPolicy.setTimeout(10000);
    retryTemplate.setRetryPolicy(retryPolicy);

    return retryTemplate.execute(context -> {
        if (consul == null || consul.statusClient() == null || isEmpty(consul.statusClient().getLeader())) {
            // if we can't find a leader this means that the consul client is not usable - we'll release it
            log.warn("couldn't verify connection to Consul");
            log.info("creating a new Consul client");
            consul = newClient(consulProperties.getHostname(), consulProperties.getHttpPort());

            // throwing this exception to retry according to the policies. The last retry will throw this exception
            throw new IllegalStateException("Consul connection could not be verified");
        } else {
            log.info("Consul connection verified");
            return consul;
        }
    });
}
 
开发者ID:amirkibbar,项目名称:plum,代码行数:26,代码来源:Consul4Spring.java

示例11: retryTemplate

import org.springframework.retry.support.RetryTemplate; //导入方法依赖的package包/类
@Override
protected RetryTemplate retryTemplate() {
	RetryTemplate retry = super.retryTemplate();

	FixedBackOffPolicy backOffPolicy = new FixedBackOffPolicy();
	backOffPolicy.setBackOffPeriod(0);
	retry.setBackOffPolicy(backOffPolicy);

	return retry;
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:11,代码来源:InOrderAsyncActionServiceTest.java

示例12: isResourcesReady

import org.springframework.retry.support.RetryTemplate; //导入方法依赖的package包/类
/**
 * Ensures external dependencies are available before starting to read messages from the queue
 * @return true if startup successful, false if not
 */
public boolean isResourcesReady() {
    boolean isStartupOk = false;

    ExponentialBackOffPolicy exponentialBackOffPolicy = getExponentialBackOffPolicy();
    SimpleRetryPolicy retryPolicy = getSimpleRetryPolicy();

    RetryTemplate retryTemplate = new RetryTemplate();
    retryTemplate.setRetryPolicy(retryPolicy);
    retryTemplate.setBackOffPolicy(exponentialBackOffPolicy);
    retryTemplate.setThrowLastExceptionOnExhausted(true);

    logger.info("Waiting for Author ELB to be in healthy state");
    
    try {
        isStartupOk = retryTemplate.execute(c -> {
            boolean result = aemInstanceHelperService.isAuthorElbHealthy();
            if(!result) //Needs to be healthy
                throw new Exception("Author ELB does not appear to be in a healthy state");
            return result;
        });
    } catch (Exception e) {
        logger.error("Failed to receive healthy state from Author ELB", e);
    }
    
    return isStartupOk;
}
 
开发者ID:shinesolutions,项目名称:aem-orchestrator,代码行数:31,代码来源:ResourceReadyChecker.java

示例13: getRetryTemplate

import org.springframework.retry.support.RetryTemplate; //导入方法依赖的package包/类
@Bean
protected RetryTemplate getRetryTemplate(@Value("${controller.retryCount:3}") int retryCount, @Value("${controller.intial_delay:1000}") int initialDelay, @Value("${controller.maxInterval:10000}") int maxInterval) {
    RetryTemplate retryTemplate = new RetryTemplate();
    retryTemplate.setRetryPolicy(new SimpleRetryPolicy(retryCount, Collections.singletonMap(RestClientException.class, true)));
    ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
    backOffPolicy.setInitialInterval(initialDelay);
    backOffPolicy.setMaxInterval(maxInterval);
    retryTemplate.setBackOffPolicy(backOffPolicy);
    retryTemplate.setThrowLastExceptionOnExhausted(true);


    retryTemplate.registerListener(new DefaultListenerSupport());

    return retryTemplate;
}
 
开发者ID:oneops,项目名称:oneops,代码行数:16,代码来源:CMSClient.java

示例14: rabbitTemplate

import org.springframework.retry.support.RetryTemplate; //导入方法依赖的package包/类
@Bean
@ConditionalOnSingleCandidate(ConnectionFactory.class)
@ConditionalOnMissingBean(RabbitTemplate.class)
public RabbitTemplate rabbitTemplate() {
    RabbitTemplate template = new RabbitTemplate(connectionFactory);
    RetryTemplate retryTemplate = new RetryTemplate();
    ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
    backOffPolicy.setInitialInterval(500);
    backOffPolicy.setMultiplier(10.0);
    backOffPolicy.setMaxInterval(10000);
    retryTemplate.setBackOffPolicy(backOffPolicy);
    template.setRetryTemplate(retryTemplate);
    template.setMessageConverter(messageConverter);
    return template;
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:16,代码来源:RabbitConfiguration.java

示例15: createRetryTemplate

import org.springframework.retry.support.RetryTemplate; //导入方法依赖的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


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