Class RetryInterceptorBuilder<T extends org.aopalliance.intercept.MethodInterceptor>

java.lang.Object
org.springframework.retry.interceptor.RetryInterceptorBuilder<T>
Type Parameters:
T - The type of MethodInterceptor returned by the builder's build() method.
Direct Known Subclasses:
RetryInterceptorBuilder.CircuitBreakerInterceptorBuilder, RetryInterceptorBuilder.StatefulRetryInterceptorBuilder, RetryInterceptorBuilder.StatelessRetryInterceptorBuilder

public abstract class RetryInterceptorBuilder<T extends org.aopalliance.intercept.MethodInterceptor> extends Object

Simplified facade to make it easier and simpler to build a StatefulRetryOperationsInterceptor or (stateless) RetryOperationsInterceptor by providing a fluent interface to defining the behavior on error.

Typical example:

 StatefulRetryOperationsInterceptor interceptor = RetryInterceptorBuilder.stateful()
                .maxAttempts(5).backOffOptions(1, 2, 10) // initialInterval, multiplier,
                                                                                                        // maxInterval
                .build();
 
Since:
1.1
Author:
James Carr, Gary Russell, Artem Bilan
  • Field Details

  • Method Details

    • stateful

      Create a builder for a stateful retry interceptor.
      Returns:
      The interceptor builder.
    • circuitBreaker

      Create a builder for a circuit breaker retry interceptor.
      Returns:
      The interceptor builder.
    • stateless

      Create a builder for a stateless retry interceptor.
      Returns:
      The interceptor builder.
    • retryOperations

      public RetryInterceptorBuilder<T> retryOperations(RetryOperations retryOperations)
      Apply the retry operations - once this is set, other properties can no longer be set; can't be set if other properties have been applied.
      Parameters:
      retryOperations - The retry operations.
      Returns:
      this.
    • maxAttempts

      public RetryInterceptorBuilder<T> maxAttempts(int maxAttempts)
      Apply the max attempts - a SimpleRetryPolicy will be used. Cannot be used if a custom retry operations or retry policy has been set.
      Parameters:
      maxAttempts - the max attempts (including the initial attempt).
      Returns:
      this.
    • backOffOptions

      public RetryInterceptorBuilder<T> backOffOptions(long initialInterval, double multiplier, long maxInterval)
      Apply the backoff options. Cannot be used if a custom retry operations, or back off policy has been set.
      Parameters:
      initialInterval - The initial interval.
      multiplier - The multiplier.
      maxInterval - The max interval.
      Returns:
      this.
    • retryPolicy

      public RetryInterceptorBuilder<T> retryPolicy(RetryPolicy policy)
      Apply the retry policy - cannot be used if a custom retry template has been provided, or the max attempts or back off options or policy have been applied.
      Parameters:
      policy - The policy.
      Returns:
      this.
    • backOffPolicy

      public RetryInterceptorBuilder<T> backOffPolicy(BackOffPolicy policy)
      Apply the back off policy. Cannot be used if a custom retry operations, or back off policy has been applied.
      Parameters:
      policy - The policy.
      Returns:
      this.
    • recoverer

      public RetryInterceptorBuilder<T> recoverer(MethodInvocationRecoverer<?> recoverer)
      Apply a MethodInvocationRecoverer for the Retry interceptor.
      Parameters:
      recoverer - The recoverer.
      Returns:
      this.
    • label

      public RetryInterceptorBuilder<T> label(String label)
    • build

      public abstract T build()