• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ExponentialBackOffPolicy类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.springframework.retry.backoff.ExponentialBackOffPolicy的典型用法代码示例。如果您正苦于以下问题:Java ExponentialBackOffPolicy类的具体用法?Java ExponentialBackOffPolicy怎么用?Java ExponentialBackOffPolicy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ExponentialBackOffPolicy类属于org.springframework.retry.backoff包,在下文中一共展示了ExponentialBackOffPolicy类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: retryTemplate

import org.springframework.retry.backoff.ExponentialBackOffPolicy; //导入依赖的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


示例2: arkClientRetryTemplate

import org.springframework.retry.backoff.ExponentialBackOffPolicy; //导入依赖的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.backoff.ExponentialBackOffPolicy; //导入依赖的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: tempoApiRetryPolicy

import org.springframework.retry.backoff.ExponentialBackOffPolicy; //导入依赖的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


示例5: afterPropertiesSet

import org.springframework.retry.backoff.ExponentialBackOffPolicy; //导入依赖的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: isResourcesReady

import org.springframework.retry.backoff.ExponentialBackOffPolicy; //导入依赖的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


示例7: getExponentialBackOffPolicy

import org.springframework.retry.backoff.ExponentialBackOffPolicy; //导入依赖的package包/类
private ExponentialBackOffPolicy getExponentialBackOffPolicy() {
    ExponentialBackOffPolicy exponentialBackOffPolicy = new ExponentialBackOffPolicy();
    exponentialBackOffPolicy.setInitialInterval(waitForAuthorBackOffPeriod);
    exponentialBackOffPolicy.setMaxInterval(waitForAuthorMaxBackOffPeriod);
    exponentialBackOffPolicy.setMultiplier(waitForAuthorBackOffPeriodMultiplier);
    return exponentialBackOffPolicy;
}
 
开发者ID:shinesolutions,项目名称:aem-orchestrator,代码行数:8,代码来源:ResourceReadyChecker.java


示例8: getRetryTemplate

import org.springframework.retry.backoff.ExponentialBackOffPolicy; //导入依赖的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


示例9: rabbitTemplate

import org.springframework.retry.backoff.ExponentialBackOffPolicy; //导入依赖的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


示例10: createRetryTemplate

import org.springframework.retry.backoff.ExponentialBackOffPolicy; //导入依赖的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


示例11: onMessage

import org.springframework.retry.backoff.ExponentialBackOffPolicy; //导入依赖的package包/类
@Override
public void onMessage(Message message) {
    Event event = eventService.findOne((String) message.getMessageProperties().getHeaders().get("id"));
    if (event != null) {
        EventLog eventLog = null;
        if (event.isValid()) {
            eventLog = new EventLog(subscriptionId, event.getId(), EventStatus.PENDING,
                                    LocalDateTime.now(ZoneId.of("UTC")));
        } else {
            eventLog = new EventLog(subscriptionId, event.getId(), EventStatus.INVALID,
                                    LocalDateTime.now(ZoneId.of("UTC")));
        }
        eventLogRepository.save(eventLog);

        if (event.isValid()) {
            Subscription subscription = subscriptionRepository.findOne(subscriptionId);
            if (subscription != null) {
                ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
                backOffPolicy.setInitialInterval(subscription.getInitialInterval());
                backOffPolicy.setMaxInterval(subscription.getMaximunInterval());
                backOffPolicy.setMultiplier(subscription.getMultiplier());
                template.setBackOffPolicy(backOffPolicy);
                template.execute(context->{
                    Link payload = new Link("", "");
                    ResponseEntity response = restTemplate
                        .postForEntity(subscription.getCallbackUrl(), payload, String.class);
                    EventLog requestLog = new EventLog(subscriptionId, event.getId(), EventStatus.ACKNOWLEDGED,
                                                       LocalDateTime.now(ZoneId.of("UTC")));
                    eventLogRepository.save(requestLog);
                    return response;
                });
            }
        }
    }
}
 
开发者ID:Byteflair,项目名称:resthooks,代码行数:36,代码来源:EventConsumer.java


示例12: amqpTemplate

import org.springframework.retry.backoff.ExponentialBackOffPolicy; //导入依赖的package包/类
@Bean
AmqpTemplate amqpTemplate() {
    ExponentialBackOffPolicy policy = new ExponentialBackOffPolicy();
    policy.setInitialInterval(500);
    policy.setMaxInterval(10000);
    policy.setMultiplier(10);

    RetryTemplate retryTemplate = new RetryTemplate();
    retryTemplate.setBackOffPolicy(policy);

    RabbitTemplate template = new RabbitTemplate(getAmqpConnectionFactory());
    template.setRetryTemplate(retryTemplate);

    return template;
}
 
开发者ID:Byteflair,项目名称:resthooks,代码行数:16,代码来源:AmqpConfig.java


示例13: retryOperations

import org.springframework.retry.backoff.ExponentialBackOffPolicy; //导入依赖的package包/类
@Bean
public RetryOperations retryOperations() {
	RetryTemplate retryTemplate = new RetryTemplate();
	retryTemplate.setRetryPolicy(new SimpleRetryPolicy(3, Collections.<Class<? extends Throwable>, Boolean>singletonMap(RedisConnectionFailureException.class, true)));
	ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
	backOffPolicy.setInitialInterval(1000L);
	backOffPolicy.setMaxInterval(1000L);
	backOffPolicy.setMultiplier(2);
	retryTemplate.setBackOffPolicy(backOffPolicy);
	return retryTemplate;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:12,代码来源:FieldValueCounterSinkStoreConfiguration.java


示例14: retryOperations

import org.springframework.retry.backoff.ExponentialBackOffPolicy; //导入依赖的package包/类
@Bean
public RetryOperations retryOperations() {
	RetryTemplate retryTemplate = new RetryTemplate();
	retryTemplate.setRetryPolicy(new SimpleRetryPolicy(3,
			Collections.<Class<? extends Throwable>, Boolean>singletonMap(RedisConnectionFailureException.class, true)));
	ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
	backOffPolicy.setInitialInterval(1000L);
	backOffPolicy.setMaxInterval(1000L);
	backOffPolicy.setMultiplier(2);
	retryTemplate.setBackOffPolicy(backOffPolicy);
	return retryTemplate;
}
 
开发者ID:spring-cloud,项目名称:spring-cloud-stream-app-starters,代码行数:13,代码来源:AggregateCounterSinkStoreConfiguration.java


示例15: configureRestTemplate

import org.springframework.retry.backoff.ExponentialBackOffPolicy; //导入依赖的package包/类
/**
 * Internal API to configure RestTemplate
 *
 * @param apiKey - API key to configure authorization header
 */
private void configureRestTemplate(String apiKey) {
    ClientHttpRequestFactory requestFactory = HTTPConfig.createRequestFactory(apiKey);
    restTemplate = new RestTemplate(requestFactory);
    retryTemplate = new RetryTemplate();
    retryTemplate.setBackOffPolicy(new ExponentialBackOffPolicy());
}
 
开发者ID:AlienVault-OTX,项目名称:OTX-Java-SDK,代码行数:12,代码来源:OTXConnection.java


示例16: buildRetryTemplate

import org.springframework.retry.backoff.ExponentialBackOffPolicy; //导入依赖的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


示例17: rabbitTemplate

import org.springframework.retry.backoff.ExponentialBackOffPolicy; //导入依赖的package包/类
@Bean
RabbitTemplate rabbitTemplate(org.springframework.amqp.rabbit.connection.ConnectionFactory  cf,
                              ObjectMapper mapper) {
    RabbitTemplate template = new RabbitTemplate(cf);
    template.setExchange(EXCHANGE_NAME);
    RetryTemplate retry = new RetryTemplate();
    ExponentialBackOffPolicy backOff = new ExponentialBackOffPolicy();
    backOff.setInitialInterval(1000);
    backOff.setMultiplier(1.5);
    backOff.setMaxInterval(60000);
    retry.setBackOffPolicy(backOff);
    template.setRetryTemplate(retry);
    template.setMessageConverter(new Jackson2JsonMessageConverter(mapper));
    return template;
}
 
开发者ID:ctco,项目名称:cukes,代码行数:16,代码来源:RabbitMQConfiguration.java


示例18: createRetryTemplate

import org.springframework.retry.backoff.ExponentialBackOffPolicy; //导入依赖的package包/类
public RetryTemplate createRetryTemplate() {
    Map<Class<? extends Throwable>, Boolean> exceptions = new HashMap<>();
    exceptions.put(TaxWebServiceNonFatalException.class, true);

    RetryTemplate template = new RetryTemplate();
    SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(maxAttempts, exceptions);
    template.setRetryPolicy(retryPolicy);

    ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
    backOffPolicy.setInitialInterval(initialInterval);
    template.setBackOffPolicy(backOffPolicy);

    return template;
}
 
开发者ID:cegeka,项目名称:batchers,代码行数:15,代码来源:RetryConfig.java


示例19: statsRetryTemplate

import org.springframework.retry.backoff.ExponentialBackOffPolicy; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(name = "statsRetryTemplate")
public RetryTemplate statsRetryTemplate() {
	RetryTemplate retryTemplate = new RetryTemplate();
	ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy();
	backOffPolicy.setInitialInterval(3000L);
	backOffPolicy.setMultiplier(3);
	SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(
			statsProperties.getElastic().getMaxAttempts(),
			Collections.singletonMap(Exception.class, true));
	retryTemplate.setBackOffPolicy(backOffPolicy);
	retryTemplate.setRetryPolicy(retryPolicy);
	return retryTemplate;
}
 
开发者ID:spring-io,项目名称:initializr,代码行数:15,代码来源:InitializrStatsAutoConfiguration.java


示例20: testBackOffPolicyIsExponential

import org.springframework.retry.backoff.ExponentialBackOffPolicy; //导入依赖的package包/类
@Test
public void testBackOffPolicyIsExponential()
{
	List<Long> sleeps = newArrayList();
	ExponentialBackOffPolicy fakeBackOff = this.backOffPolicy.withSleeper(sleeps::add);
	BackOffContext context = fakeBackOff.start(null);
	for (int i = 0; i < 11; i++)
	{
		fakeBackOff.backOff(context);
	}
	assertEquals(sleeps,
			Arrays.asList(1000L, 2000L, 4000L, 8000L, 16000L, 32000L, 64000L, 128000L, 256000L, 300000L, 300000L));
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:14,代码来源:ConnectionRetryConfigTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TextUtilities类代码示例发布时间:2022-05-21
下一篇:
Java IRecordProcessor类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap