|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.batch.retry.interceptor.StatefulRetryOperationsInterceptor
public class StatefulRetryOperationsInterceptor
A MethodInterceptor
that can be used to automatically retry calls to
a method on a service if it fails. The argument to the service method is
treated as an item to be remembered in case the call fails. So the retry
operation is stateful, and the item that failed is tracked by its unique key
(via ItemKeyGenerator
) until the retry is exhausted, at which point
the ItemRecoverer
is called.
The main use case for this is where the service is transactional, via a
transaction interceptor on the interceptor chain. In this case the retry (and
recovery on exhausted) always happens in a new transaction.
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
.
Constructor Summary | |
---|---|
StatefulRetryOperationsInterceptor()
|
Method Summary | |
---|---|
Object |
invoke(org.aopalliance.intercept.MethodInvocation invocation)
Wrap the method invocation in a stateful retry with the policy and other helpers provided. |
void |
setKeyGenerator(ItemKeyGenerator keyGenerator)
|
void |
setNewItemIdentifier(NewItemIdentifier newItemIdentifier)
Public setter for the NewItemIdentifier . |
void |
setRecoverer(ItemRecoverer recoverer)
Public setter for the ItemRecoverer to use if the retry is
exhausted. |
void |
setRetryPolicy(RetryPolicy retryPolicy)
Public setter for the retryPolicy. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StatefulRetryOperationsInterceptor()
Method Detail |
---|
public void setRecoverer(ItemRecoverer recoverer)
ItemRecoverer
to use if the retry is
exhausted. The recoverer should be able to return an object of the same
type as the target object because its return value will be used to return
to the caller in the case of a recovery.ExhaustedRetryException
.
recoverer
- the ItemRecoverer
to setpublic void setKeyGenerator(ItemKeyGenerator keyGenerator)
public void setRetryPolicy(RetryPolicy retryPolicy)
retryPolicy
- the retryPolicy to setpublic void setNewItemIdentifier(NewItemIdentifier newItemIdentifier)
NewItemIdentifier
. Only set this if the
arguments to the intercepted method can be inspected to find out if they
have never been processed before.
newItemIdentifier
- the NewItemIdentifier
to setpublic Object invoke(org.aopalliance.intercept.MethodInvocation invocation) throws Throwable
ItemRecoverer
provided
if there is one). In that case the value returned from the method
invocation will be the value returned by the recoverer (so the return
type for that should be the same as the intercepted method).
invoke
in interface org.aopalliance.intercept.MethodInterceptor
ExhaustedRetryException
- if the retry is exhausted and no
ItemRecoverer
is provided.
Throwable
MethodInterceptor.invoke(org.aopalliance.intercept.MethodInvocation)
,
ItemRecoverer.recover(Object, Throwable)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |