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

java.lang.Object
cn.taketoday.retry.interceptor.RetryInterceptorBuilder<T>
类型参数:
T - The type of MethodInterceptor returned by the builder's build() method.
直接已知子类:
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();
 
从以下版本开始:
4.0
作者:
James Carr, Gary Russell, Artem Bilan
  • 字段详细资料

    • retryTemplate

      protected final RetryTemplate retryTemplate
    • simpleRetryPolicy

      protected final SimpleRetryPolicy simpleRetryPolicy
    • retryOperations

      protected RetryOperations retryOperations
    • recoverer

      protected MethodInvocationRecoverer<?> recoverer
    • templateAltered

      private boolean templateAltered
    • backOffPolicySet

      private boolean backOffPolicySet
    • retryPolicySet

      private boolean retryPolicySet
    • backOffOptionsSet

      private boolean backOffOptionsSet
    • label

      protected String label
  • 构造器详细资料

    • RetryInterceptorBuilder

      private RetryInterceptorBuilder()
  • 方法详细资料

    • stateful

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

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

      Create a builder for a stateless retry interceptor.
      返回:
      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.
      参数:
      retryOperations - The retry operations.
      返回:
      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.
      参数:
      maxAttempts - the max attempts (including the initial attempt).
      返回:
      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.
      参数:
      initialInterval - The initial interval.
      multiplier - The multiplier.
      maxInterval - The max interval.
      返回:
      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.
      参数:
      policy - The policy.
      返回:
      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.
      参数:
      policy - The policy.
      返回:
      this.
    • recoverer

      public RetryInterceptorBuilder<T> recoverer(MethodInvocationRecoverer<?> recoverer)
      Apply a MethodInvocationRecoverer for the Retry interceptor.
      参数:
      recoverer - The recoverer.
      返回:
      this.
    • label

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

      public abstract T build()