Class RetryInterceptorBuilder<T extends org.aopalliance.intercept.MethodInterceptor>
java.lang.Object
org.springframework.retry.interceptor.RetryInterceptorBuilder<T>
- Type Parameters:
T
- The type ofMethodInterceptor
returned by the builder'sbuild()
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
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
static class
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
protected MethodInvocationRecoverer<?>
protected RetryOperations
protected final RetryTemplate
protected final SimpleRetryPolicy
-
Method Summary
Modifier and TypeMethodDescriptionbackOffOptions
(long initialInterval, double multiplier, long maxInterval) Apply the backoff options.backOffPolicy
(BackOffPolicy policy) Apply the back off policy.abstract T
build()
Create a builder for a circuit breaker retry interceptor.maxAttempts
(int maxAttempts) Apply the max attempts - a SimpleRetryPolicy will be used.recoverer
(MethodInvocationRecoverer<?> recoverer) Apply aMethodInvocationRecoverer
for the Retry interceptor.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.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.stateful()
Create a builder for a stateful retry interceptor.Create a builder for a stateless retry interceptor.
-
Field Details
-
retryTemplate
-
simpleRetryPolicy
-
retryOperations
-
recoverer
-
label
-
-
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
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
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
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
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
Apply aMethodInvocationRecoverer
for the Retry interceptor.- Parameters:
recoverer
- The recoverer.- Returns:
- this.
-
label
-
build
-