protected ExponentialBackOffPolicy newInstance() { return new ExponentialBackOffPolicy(); }
@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( this.statsProperties.getElastic().getMaxAttempts(), Collections.singletonMap(Exception.class, true)); retryTemplate.setBackOffPolicy(backOffPolicy); retryTemplate.setRetryPolicy(retryPolicy); return retryTemplate; }
/** * Apply the backoff options. Cannot be used if a custom retry operations, or back off * policy has been set. * @param initialInterval The initial interval. * @param multiplier The multiplier. * @param maxInterval The max interval. * @return this. */ public RetryInterceptorBuilder<T> backOffOptions(long initialInterval, double multiplier, long maxInterval) { Assert.isNull(this.retryOperations, "cannot set the back off policy when a custom retryOperations has been set"); Assert.isTrue(!this.backOffPolicySet, "cannot set the back off options when a back off policy has been set"); ExponentialBackOffPolicy policy = new ExponentialBackOffPolicy(); policy.setInitialInterval(initialInterval); policy.setMultiplier(multiplier); policy.setMaxInterval(maxInterval); this.retryTemplate.setBackOffPolicy(policy); this.backOffOptionsSet = true; this.templateAltered = true; return this; }
ExponentialBackOffPolicy policy = new ExponentialBackOffPolicy(); if (backoff.random()) { policy = new ExponentialRandomBackOffPolicy();
public void restart(final int index) throws Exception { //NOSONAR // retry restarting repeatedly, first attempts may fail SimpleRetryPolicy retryPolicy = new SimpleRetryPolicy(10, // NOSONAR magic # Collections.singletonMap(Exception.class, true)); ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy(); backOffPolicy.setInitialInterval(100); // NOSONAR magic # backOffPolicy.setMaxInterval(1000); // NOSONAR magic # backOffPolicy.setMultiplier(2); // NOSONAR magic # RetryTemplate retryTemplate = new RetryTemplate(); retryTemplate.setRetryPolicy(retryPolicy); retryTemplate.setBackOffPolicy(backOffPolicy); retryTemplate.execute(context -> { this.kafkaServers.get(index).startup(); return null; }); }
protected ExponentialBackOffPolicy newInstance() { return new ExponentialBackOffPolicy(); }
protected ExponentialBackOffPolicy createBackOffPolicy() { ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy(); backOffPolicy.setMultiplier(5.0D); return backOffPolicy; }
protected ExponentialBackOffPolicy createBackOffPolicy() { ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy(); backOffPolicy.setMultiplier(5.0D); return backOffPolicy; }
@Override public BackOffPolicy createBackOffPolicy(String service) { final ExponentialBackOffPolicy backoffPolicy = new ExponentialBackOffPolicy(); backoffPolicy.setMultiplier(backoffMultiplier); backoffPolicy.setInitialInterval(initialBackoffInterval); backoffPolicy.setMaxInterval(maxInterval); return backoffPolicy; } };
private ExponentialBackOffPolicy exponentialBackOffPolicy() { ExponentialBackOffPolicy exponentialBackOffPolicy = new ExponentialBackOffPolicy(); exponentialBackOffPolicy.setInitialInterval(initialInterval); exponentialBackOffPolicy.setMaxInterval(maxInterval); exponentialBackOffPolicy.setMultiplier(multiplier); return exponentialBackOffPolicy; }
@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; }
@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; }
@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; }
@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; }
@Configuration public class RetryConfiguration { @Bean RetryTemplate retryTemplate() { RetryTemplate template = new RetryTemplate(); TimeoutRetryPolicy policy = new TimeoutRetryPolicy(); policy.setTimeout(30000L); template.setRetryPolicy(policy); ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy(); template.setBackOffPolicy(backOffPolicy); return template; } }
@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( this.statsProperties.getElastic().getMaxAttempts(), Collections.singletonMap(Exception.class, true)); retryTemplate.setBackOffPolicy(backOffPolicy); retryTemplate.setRetryPolicy(retryPolicy); return retryTemplate; }
@Bean public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory) { // TODO: 05.03.18 Guil: // Set these static values on the applications.properties RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory); rabbitTemplate.setReplyTimeout(10000); rabbitTemplate.setReceiveTimeout(10000); RetryTemplate retryTemplate = new RetryTemplate(); ExponentialBackOffPolicy backOffPolicy = new ExponentialBackOffPolicy(); backOffPolicy.setInitialInterval(500); backOffPolicy.setMultiplier(10.0); backOffPolicy.setMaxInterval(10000); retryTemplate.setBackOffPolicy(backOffPolicy); rabbitTemplate.setRetryTemplate(retryTemplate); return rabbitTemplate; }
@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; } }
@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; } }
@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; } }