Annotation Interface Retryable
Annotation for a method invocation that is retryable.
- Since:
- 1.1
- Author:
- Dave Syer, Artem Bilan, Gary Russell, Maksim Kita, Roman Akentev
-
Optional Element Summary
Modifier and TypeOptional ElementDescriptionSpecify the backoff properties for retrying this operation.Specify an expression to be evaluated after theSimpleRetryPolicy.canRetry()
returns true - can be used to conditionally suppress the retry.Deprecated.Deprecated.in favor ofretryFor()
.Retry interceptor bean name to be applied for retryable method.A unique label for statistics reporting.String[]
Bean names of retry listeners to use instead of default ones defined in Spring context.int
Exception types that are not retryable.Exception types that are not recoverable; these exceptions are thrown to the caller without calling any recoverer (immediately if also innoRetryFor()
).Name of method in this class to use for recover.Exception types that are retryable.boolean
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.Deprecated.in favor ofretryFor()
-
Element Details
-
recover
String recoverName of method in this class to use for recover. Method had to be marked withRecover
annotation.- Returns:
- the name of recover method
- Default:
- ""
-
interceptor
String interceptorRetry interceptor bean name to be applied for retryable method. Is mutually exclusive with other attributes.- Returns:
- the retry interceptor bean name
- Default:
- ""
-
value
Deprecated.in favor ofretryFor()
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
Deprecated.in favor ofretryFor()
.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
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.in favor ofnoRetryFor()
.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
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
Exception types that are not recoverable; these exceptions are thrown to the caller without calling any recoverer (immediately if also innoRetryFor()
). Defaults to empty.- Returns:
- exception types not to retry
- Since:
- 2.0
- Default:
- {}
-
label
String labelA 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 statefulFlag 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 backoffSpecify the backoff properties for retrying this operation. The default is a simpleBackoff
specification with no properties - see its documentation for defaults.- Returns:
- a backoff specification
- Default:
- @org.springframework.retry.annotation.Backoff
-
exceptionExpression
String exceptionExpressionSpecify an expression to be evaluated after theSimpleRetryPolicy.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 lastThrowable
. Other beans in the context can be referenced. For example:"message.contains('you can retry this')"
."@someBean.shouldRetry(#root)"
.- Returns:
- the expression.
- Since:
- 1.2
- Default:
- ""
-
listeners
String[] listenersBean 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:
- {}
-
noRetryFor()
.