Class RetryOperationsInterceptor
java.lang.Object
org.springframework.retry.interceptor.RetryOperationsInterceptor
- All Implemented Interfaces:
org.aopalliance.aop.Advice
,org.aopalliance.intercept.Interceptor
,org.aopalliance.intercept.MethodInterceptor
public class RetryOperationsInterceptor
extends Object
implements org.aopalliance.intercept.MethodInterceptor
A
MethodInterceptor
that can be used to automatically retry calls to a method
on a service if it fails. The injected RetryOperations
is used to control the
number of retries. By default, it will retry a fixed number of times, according to the
defaults in RetryTemplate
.
Hint about transaction boundaries. If you want to retry a failed transaction you need to make sure that the transaction boundary is inside the retry, otherwise the successful attempt will roll back with the whole transaction. If the method being intercepted is also transactional, then use the ordering hints in the advice declarations to ensure that this one is before the transaction interceptor in the advice chain.
An internal MethodInvocationRetryCallback
implementation exposes a
"method" attribute into the provided
RetryContext
with a value from MethodInvocation.getMethod()
. In
addition, the arguments of this method are exposed into a
"methodArgs" attribute as an Args
instance
wrapper.
- Author:
- Rob Harrop, Dave Syer, Artem Bilan
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
TheRetryContext
attribute name for theMethodInvocation.getMethod()
.static final String
TheRetryContext
attribute name for thenew Args(invocation.getArguments())
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioninvoke
(org.aopalliance.intercept.MethodInvocation invocation) void
void
setRecoverer
(MethodInvocationRecoverer<?> recoverer) void
setRetryOperations
(RetryOperations retryTemplate)
-
Field Details
-
METHOD
TheRetryContext
attribute name for theMethodInvocation.getMethod()
.- See Also:
-
METHOD_ARGS
TheRetryContext
attribute name for thenew Args(invocation.getArguments())
.- See Also:
-
-
Constructor Details
-
RetryOperationsInterceptor
public RetryOperationsInterceptor()
-
-
Method Details
-
setLabel
-
setRetryOperations
-
setRecoverer
-
invoke
- Specified by:
invoke
in interfaceorg.aopalliance.intercept.MethodInterceptor
- Throws:
Throwable
-