congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
RetryTemplate.setBackOffPolicy
Code IndexAdd Tabnine to your IDE (free)

How to use
setBackOffPolicy
method
in
org.springframework.retry.support.RetryTemplate

Best Java code snippets using org.springframework.retry.support.RetryTemplate.setBackOffPolicy (Showing top 20 results out of 333)

origin: spring-projects/spring-batch

public void setBackOffPolicy(BackOffPolicy backOffPolicy) {
  delegate.setBackOffPolicy(backOffPolicy);
  regular.setBackOffPolicy(backOffPolicy);
}
origin: spring-projects/spring-retry

/**
 * Apply the back off policy. Cannot be used if a custom retry operations, or back off
 * policy has been applied.
 * @param policy The policy.
 * @return this.
 */
public RetryInterceptorBuilder<T> backOffPolicy(BackOffPolicy policy) {
  Assert.isNull(this.retryOperations,
      "cannot set the back off policy when a custom retryOperations has been set");
  Assert.isTrue(!this.backOffOptionsSet,
      "cannot set the back off policy when the back off policy options have been set");
  this.retryTemplate.setBackOffPolicy(policy);
  this.templateAltered = true;
  this.backOffPolicySet = true;
  return this;
}
origin: spring-io/initializr

@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;
}
origin: spring-projects/spring-retry

/**
 * 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;
}
origin: spring-projects/spring-retry

/**
 * Execute a single simulation
 * @return The sleeps which occurred within the single simulation.
 */
public List<Long> executeSingleSimulation() {
  StealingSleeper stealingSleeper = new StealingSleeper();
  SleepingBackOffPolicy<?> stealingBackoff = backOffPolicy.withSleeper(stealingSleeper);
  RetryTemplate template = new RetryTemplate();
  template.setBackOffPolicy(stealingBackoff);
  template.setRetryPolicy(retryPolicy);
  try {
    template.execute(new FailingRetryCallback());
  } catch(FailingRetryException e) {
  } catch(Throwable e) {
    throw new RuntimeException("Unexpected exception", e);
  }
  return stealingSleeper.getSleeps();
}
origin: spring-projects/spring-retry

private MethodInterceptor getStatelessInterceptor(Object target, Method method, Retryable retryable) {
  RetryTemplate template = createTemplate(retryable.listeners());
  template.setRetryPolicy(getRetryPolicy(retryable));
  template.setBackOffPolicy(getBackoffPolicy(retryable.backoff()));
  return RetryInterceptorBuilder.stateless()
      .retryOperations(template)
      .label(retryable.label())
      .recoverer(getRecoverer(target, method))
      .build();
}
origin: spring-projects/spring-retry

  breaker.setResetTimeout(getResetTimeout(circuit));
  template.setRetryPolicy(breaker);
  template.setBackOffPolicy(new NoBackOffPolicy());
  String label = circuit.label();
  if (!StringUtils.hasText(label))  {
template.setBackOffPolicy(getBackoffPolicy(retryable.backoff()));
String label = retryable.label();
return RetryInterceptorBuilder.stateful()
origin: spring-projects/spring-kafka

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;
  });
}
origin: org.springframework.cloud/spring-cloud-commons

  private RetryTemplate createRetryTemplate(String serviceName, HttpRequest request, LoadBalancedRetryPolicy retryPolicy) {
    RetryTemplate template = new RetryTemplate();
    BackOffPolicy backOffPolicy = lbRetryFactory.createBackOffPolicy(serviceName);
    template.setBackOffPolicy(backOffPolicy == null ? new NoBackOffPolicy() : backOffPolicy);
    template.setThrowLastExceptionOnExhausted(true);
    RetryListener[] retryListeners = lbRetryFactory.createRetryListeners(serviceName);
    if (retryListeners != null && retryListeners.length != 0) {
      template.setListeners(retryListeners);
    }
    template.setRetryPolicy(
        !lbProperties.isEnabled() || retryPolicy == null ? new NeverRetryPolicy()
            : new InterceptorRetryPolicy(request, retryPolicy, loadBalancer,
            serviceName));
    return template;
  }
}
origin: org.springframework.batch/spring-batch-core

public void setBackOffPolicy(BackOffPolicy backOffPolicy) {
  delegate.setBackOffPolicy(backOffPolicy);
  regular.setBackOffPolicy(backOffPolicy);
}
origin: com.github.almex/raildelays-batch

@Override
public void afterPropertiesSet() throws Exception {
  // Validate all job parameters
  Assert.notNull(parser, "The 'parser' property must have a value");
  Assert.notNull(request, "The 'request' property must have a value");
  Assert.notNull(streamer, "The 'streamer' property must have a value");
  Assert.notNull(retryPolicy, "The 'retryPolicy' property must have a value");
  Assert.notNull(backOffPolicy, "The 'backOffPolicy' property must have a value");
  retryTemplate = new RetryTemplate();
  retryTemplate.setRetryPolicy(retryPolicy);
  retryTemplate.setBackOffPolicy(backOffPolicy);
}
origin: spring-projects/spring-amqp

/**
 * Apply the back off policy. Cannot be used if a custom retry operations, or back off policy has been applied.
 * @param policy The policy.
 * @return this.
 */
public B backOffPolicy(BackOffPolicy policy) {
  Assert.isNull(this.retryOperations, "cannot set the back off policy when a custom retryOperations has been set");
  Assert.isTrue(!this.backOffOptionsSet, "cannot set the back off policy when the back off policy options have been set");
  this.retryTemplate.setBackOffPolicy(policy);
  this.templateAltered = true;
  this.backOffPolicySet = true;
  return _this();
}
origin: spring-cloud/spring-cloud-stream-app-starters

@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;
}
origin: zalando-incubator/catwatch

private RetryTemplate retryTemplate() {
  RetryTemplate template = new RetryTemplate();
  template.setBackOffPolicy(exponentialBackOffPolicy());
  template.setRetryPolicy(retryPolicy());
  return template;
}
origin: org.springframework.cloud.stream.app/spring-cloud-starter-stream-sink-field-value-counter

@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;
}
origin: org.slinkyframework/slinky-environment-builder-couchbase

private void waitFor(BiConsumer<String, CouchbaseBuildDefinition> function, String host, CouchbaseBuildDefinition buildDefinition) {
  TimeoutRetryPolicy retryPolicy = new TimeoutRetryPolicy();
  retryPolicy.setTimeout(THIRTY_SECONDS);
  FixedBackOffPolicy backOffPolicy = new FixedBackOffPolicy();
  backOffPolicy.setBackOffPeriod(ONE_SECOND);
  RetryTemplate retryTemplate = new RetryTemplate();
  retryTemplate.setRetryPolicy(retryPolicy);
  retryTemplate.setThrowLastExceptionOnExhausted(true);
  retryTemplate.setBackOffPolicy(backOffPolicy);
  retryTemplate.execute(rc -> { function.accept(host, buildDefinition); return null; });
}
origin: org.slinkyframework/slinky-environment-builder-couchbase

private void waitFor(BiConsumer<Bucket, CouchbaseBuildDefinition> function, Bucket bucket, CouchbaseBuildDefinition buildDefinition) {
  TimeoutRetryPolicy retryPolicy = new TimeoutRetryPolicy();
  retryPolicy.setTimeout(THIRTY_SECONDS);
  FixedBackOffPolicy backOffPolicy = new FixedBackOffPolicy();
  backOffPolicy.setBackOffPeriod(ONE_SECOND);
  RetryTemplate retryTemplate = new RetryTemplate();
  retryTemplate.setRetryPolicy(retryPolicy);
  retryTemplate.setThrowLastExceptionOnExhausted(true);
  retryTemplate.setBackOffPolicy(backOffPolicy);
  retryTemplate.execute(rc -> { function.accept(bucket, buildDefinition); return null; });
}
origin: org.slinkyframework.environment/slinky-common-docker

private void waitForContainerToStart() {
  TimeoutRetryPolicy retryPolicy = new TimeoutRetryPolicy();
  retryPolicy.setTimeout(THIRTY_SECONDS);
  FixedBackOffPolicy backOffPolicy = new FixedBackOffPolicy();
  backOffPolicy.setBackOffPeriod(ONE_SECOND);
  RetryTemplate retryTemplate = new RetryTemplate();
  retryTemplate.setRetryPolicy(retryPolicy);
  retryTemplate.setThrowLastExceptionOnExhausted(true);
  retryTemplate.setBackOffPolicy(backOffPolicy);
  retryTemplate.execute(rc -> portInUse(dockerHostname, firstExternalPort()));
}
origin: com.dell.cpsd.common.messaging/common-rabbitmq

public DefaultRetryPolicyAdvice(MessageRecoverer messageRecoverer, RetryPolicy retryPolicy)
{
  RetryTemplate retryTemplate = new RetryTemplate();
  retryTemplate.setBackOffPolicy(createBackOffPolicy());
  retryTemplate.setRetryPolicy(retryPolicy);
  retryTemplate.registerListener(new RetryErrorListener());
  StatefulRetryOperationsInterceptorFactoryBean factory = new StatefulRetryOperationsInterceptorFactoryBean();
  factory.setRetryOperations(retryTemplate);
  factory.setMessageKeyGenerator(new DefaultMessageKeyGenerator());
  factory.setMessageRecoverer(messageRecoverer);
  this.delegate = factory.getObject();
}
origin: org.springframework.retry/spring-retry

private MethodInterceptor getStatelessInterceptor(Object target, Method method, Retryable retryable) {
  RetryTemplate template = createTemplate(retryable.listeners());
  template.setRetryPolicy(getRetryPolicy(retryable));
  template.setBackOffPolicy(getBackoffPolicy(retryable.backoff()));
  return RetryInterceptorBuilder.stateless()
      .retryOperations(template)
      .label(retryable.label())
      .recoverer(getRecoverer(target, method))
      .build();
}
org.springframework.retry.supportRetryTemplatesetBackOffPolicy

Javadoc

Setter for BackOffPolicy.

Popular methods of RetryTemplate

  • <init>
  • setRetryPolicy
    Setter for RetryPolicy.
  • execute
    Execute the callback once if the policy dictates that we can, re-throwing any exception encountered
  • registerListener
    Register an additional listener.
  • setListeners
    Setter for listeners. The listeners are executed before and after a retry block (i.e. before and aft
  • setRetryContextCache
    Public setter for the RetryContextCache.
  • canRetry
    Decide whether to proceed with the ongoing retry attempt. This method is called before the RetryCall
  • close
    Clean up the cache if necessary and close the context provided (if the flag indicates that processin
  • handleRetryExhausted
    Actions to take after final attempt has failed. If there is state clean up the cache. If there is a
  • open
    Delegate to the RetryPolicy having checked in the cache for an existing value if the state is not nu
  • registerThrowable
  • setThrowLastExceptionOnExhausted
  • registerThrowable,
  • setThrowLastExceptionOnExhausted,
  • doCloseInterceptors,
  • doExecute,
  • doOnErrorInterceptors,
  • doOpenInterceptors,
  • doOpenInternal,
  • registerContext,
  • rethrow

Popular in Java

  • Updating database using SQL prepared statement
  • getSupportFragmentManager (FragmentActivity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • runOnUiThread (Activity)
  • BorderLayout (java.awt)
    A border layout lays out a container, arranging and resizing its components to fit in five regions:
  • Dictionary (java.util)
    Note: Do not use this class since it is obsolete. Please use the Map interface for new implementatio
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • JTextField (javax.swing)
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no
  • Sublime Text for Python
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now