Annotation Interface Retryable


@Target({METHOD,TYPE}) @Retention(RUNTIME) @Documented public @interface Retryable
Annotation for a method invocation that is retryable.
Since:
1.1
Author:
Dave Syer, Artem Bilan, Gary Russell, Maksim Kita, Roman Akentev
  • Element Details

    • recover

      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
      Default:
      ""
    • interceptor

      String interceptor
      Retry interceptor bean name to be applied for retryable method. Is mutually exclusive with other attributes.
      Returns:
      the retry interceptor bean name
      Default:
      ""
    • value

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

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

      @AliasFor("include") 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("noRetryFor") Class<? extends Throwable>[] exclude
      Deprecated.
      in favor of noRetryFor().
      Exception types that are not retryable. Defaults to empty (and if include is also empty all exceptions are retried). If includes is empty but exclude is not, all not excluded exceptions are retried
      Returns:
      exception types not to retry
      Default:
      {}
    • noRetryFor

      @AliasFor("exclude") 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 noRetryFor is not, all other exceptions are retried
      Returns:
      exception types not to retry
      Since:
      2.0
      Default:
      {}
    • notRecoverable

      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:
      {}
    • label

      String label
      A unique label for statistics reporting. If not provided the caller may choose to ignore it, or provide a default.
      Returns:
      the label for the statistics
      Default:
      ""
    • stateful

      boolean stateful
      Flag to say that the retry is stateful: i.e. exceptions are re-thrown, but the retry policy is applied with the same policy to subsequent invocations with the same arguments. If false then retryable exceptions are not re-thrown.
      Returns:
      true if retry is stateful, default false
      Default:
      false
    • maxAttempts

      int maxAttempts
      Returns:
      the maximum number of attempts (including the first failure), defaults to 3
      Default:
      3
    • maxAttemptsExpression

      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
      Default:
      ""
    • backoff

      Backoff backoff
      Specify the backoff properties for retrying this operation. The default is a simple Backoff specification with no properties - see its documentation for defaults.
      Returns:
      a backoff specification
      Default:
      @org.springframework.retry.annotation.Backoff
    • exceptionExpression

      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
      Default:
      ""
    • listeners

      String[] listeners
      Bean names of retry listeners to use instead of default ones defined in Spring context. If this attribute is set to an empty string "", it will effectively exclude all retry listeners, including with the default listener beans, from being used.
      Returns:
      retry listeners bean names
      Default:
      {}