Annotation Interface CircuitBreaker


@Target({METHOD,TYPE}) @Retention(RUNTIME) @Documented @Retryable(stateful=true) public @interface CircuitBreaker
Annotation for a method invocation that is retryable.
Since:
1.2
Author:
Dave Syer, Artem Bilan, Gary Russell
  • Element Details

    • value

      @AliasFor(annotation=Retryable.class) @Deprecated Class<? extends Throwable>[] value
      Deprecated.
      in favor of retryFor()
      Exception types that are retryable. Defaults to empty (and if excludes is also empty all exceptions are retried).
      Returns:
      exception types to retry
      Default:
      {}
    • include

      @AliasFor(annotation=Retryable.class) @Deprecated Class<? extends Throwable>[] include
      Deprecated.
      in favor of retryFor().
      Exception types that are retryable. Defaults to empty (and if excludes is also empty all exceptions are retried).
      Returns:
      exception types to retry
      Default:
      {}
    • retryFor

      @AliasFor(annotation=Retryable.class) Class<? extends Throwable>[] retryFor
      Exception types that are retryable. Defaults to empty (and, if noRetryFor is also empty, all exceptions are retried).
      Returns:
      exception types to retry
      Since:
      2.0
      Default:
      {}
    • exclude

      @Deprecated @AliasFor(annotation=Retryable.class) Class<? extends Throwable>[] exclude
      Deprecated.
      in favor of noRetryFor().
      Exception types that are not retryable. Defaults to empty (and if includes is also empty all exceptions are retried). If includes is empty but excludes is not, all not excluded exceptions are retried
      Returns:
      exception types not to retry
      Default:
      {}
    • noRetryFor

      @AliasFor(annotation=Retryable.class) Class<? extends Throwable>[] noRetryFor
      Exception types that are not retryable. Defaults to empty (and, if retryFor is also empty, all exceptions are retried). If retryFor is empty but excludes is not, all other exceptions are retried
      Returns:
      exception types not to retry
      Since:
      2.0
      Default:
      {}
    • notRecoverable

      @AliasFor(annotation=Retryable.class) Class<? extends Throwable>[] notRecoverable
      Exception types that are not recoverable; these exceptions are thrown to the caller without calling any recoverer (immediately if also in noRetryFor()). Defaults to empty.
      Returns:
      exception types not to retry
      Since:
      2.0
      Default:
      {}
    • maxAttempts

      @AliasFor(annotation=Retryable.class) int maxAttempts
      Returns:
      the maximum number of attempts (including the first failure), defaults to 3
      Default:
      3
    • maxAttemptsExpression

      @AliasFor(annotation=Retryable.class) String maxAttemptsExpression
      Returns:
      an expression evaluated to the maximum number of attempts (including the first failure), defaults to 3 Overrides maxAttempts(). Use #{...} for one-time evaluation during initialization, omit the delimiters for evaluation at runtime.
      Since:
      1.2.3
      Default:
      ""
    • label

      @AliasFor(annotation=Retryable.class) String label
      A unique label for the circuit for reporting and state management. Defaults to the method signature where the annotation is declared.
      Returns:
      the label for the circuit
      Default:
      ""
    • resetTimeout

      long resetTimeout
      If the circuit is open for longer than this timeout then it resets on the next call to give the downstream component a chance to respond again.
      Returns:
      the timeout before an open circuit is reset in milliseconds, defaults to 20000
      Default:
      20000L
    • resetTimeoutExpression

      String resetTimeoutExpression
      If the circuit is open for longer than this timeout then it resets on the next call to give the downstream component a chance to respond again. Overrides resetTimeout(). Use #{...} for one-time evaluation during initialization, omit the delimiters for evaluation at runtime.
      Returns:
      the timeout before an open circuit is reset in milliseconds, no default.
      Since:
      1.2.3
      Default:
      ""
    • openTimeout

      long openTimeout
      When maxAttempts() failures are reached within this timeout, the circuit is opened automatically, preventing access to the downstream component.
      Returns:
      the timeout before a closed circuit is opened in milliseconds, defaults to 5000
      Default:
      5000L
    • openTimeoutExpression

      String openTimeoutExpression
      When maxAttempts() failures are reached within this timeout, the circuit is opened automatically, preventing access to the downstream component. Overrides openTimeout(). Use #{...} for one-time evaluation during initialization, omit the delimiters for evaluation at runtime.
      Returns:
      the timeout before a closed circuit is opened in milliseconds, no default.
      Since:
      1.2.3
      Default:
      ""
    • exceptionExpression

      @AliasFor(annotation=Retryable.class) String exceptionExpression
      Specify an expression to be evaluated after the SimpleRetryPolicy.canRetry() returns true - can be used to conditionally suppress the retry. Only invoked after an exception is thrown. The root object for the evaluation is the last Throwable. Other beans in the context can be referenced. For example:
        "message.contains('you can retry this')".
       
      and
        "@someBean.shouldRetry(#root)".
       
      Returns:
      the expression.
      Since:
      1.2.3
      Default:
      ""
    • throwLastExceptionOnExhausted

      boolean throwLastExceptionOnExhausted
      Set to true to not wrap last exception to the ExhaustedRetryException when retry is exhausted.
      Returns:
      the boolean flag to whether wrap the last exception to the ExhaustedRetryException
      Since:
      2.0.6
      Default:
      false
    • recover

      @AliasFor(annotation=Retryable.class) String recover
      Name of method in this class to use for recover. Method had to be marked with Recover annotation.
      Returns:
      the name of recover method
      Since:
      2.0.9
      Default:
      ""