|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.batch.core.step.item.BatchRetryTemplate
public class BatchRetryTemplate
A special purpose retry template that deals specifically with multi-valued
stateful retry. This is useful in the case where the operation to be retried
operates on multiple items, and when it fails there is no way to decide which
(if any) of the items was responsible. The RetryState
used in the
execute methods is composite, and when a failure occurs, all of the keys in
the composite are "tarred with the same brush". Subsequent attempts to
execute with any of the keys that have failed previously results in a new
attempt and the previous state is used to check the RetryPolicy
. If
one of the failed items eventually succeeds then the others in the current
composite for that attempt will be cleared from the context cache (as
normal), but there may still be entries in the cache for the original failed
items. This might mean that an item that did not cause a failure is never
retried because other items in the same batch fail fatally first.
Constructor Summary | |
---|---|
BatchRetryTemplate()
|
Method Summary | ||
---|---|---|
boolean |
canRetry(RetryContext context)
|
|
static List<RetryState> |
createState(List<?> keys)
|
|
static List<RetryState> |
createState(List<?> keys,
Classifier<? super Throwable,Boolean> classifier)
|
|
|
execute(RetryCallback<T> retryCallback)
Execute the supplied RetryCallback with the configured retry
semantics. |
|
|
execute(RetryCallback<T> retryCallback,
Collection<RetryState> states)
|
|
|
execute(RetryCallback<T> retryCallback,
RecoveryCallback<T> recoveryCallback)
Execute the supplied RetryCallback with a fallback on exhausted
retry to the RecoveryCallback . |
|
|
execute(RetryCallback<T> retryCallback,
RecoveryCallback<T> recoveryCallback,
Collection<RetryState> states)
|
|
|
execute(RetryCallback<T> retryCallback,
RecoveryCallback<T> recoveryCallback,
RetryState retryState)
A stateful retry with a recovery path. |
|
|
execute(RetryCallback<T> retryCallback,
RetryState retryState)
A simple stateful retry. |
|
void |
registerListener(RetryListener listener)
|
|
void |
setBackOffPolicy(BackOffPolicy backOffPolicy)
|
|
void |
setListeners(RetryListener[] listeners)
|
|
void |
setRetryContextCache(RetryContextCache retryContextCache)
|
|
void |
setRetryPolicy(RetryPolicy retryPolicy)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BatchRetryTemplate()
Method Detail |
---|
public <T> T execute(RetryCallback<T> retryCallback, Collection<RetryState> states) throws ExhaustedRetryException, Exception
ExhaustedRetryException
Exception
public <T> T execute(RetryCallback<T> retryCallback, RecoveryCallback<T> recoveryCallback, Collection<RetryState> states) throws ExhaustedRetryException, Exception
ExhaustedRetryException
Exception
public final <T> T execute(RetryCallback<T> retryCallback, RecoveryCallback<T> recoveryCallback, RetryState retryState) throws Exception, ExhaustedRetryException
RetryOperations
RetryCallback
with a fallback on exhausted retry to the
RecoveryCallback
and a target object for the retry attempt
identified by the DefaultRetryState
.
execute
in interface RetryOperations
RetryCallback
upon successful
invocation, and that returned by the RecoveryCallback
otherwise.
Exception
- any Exception
raised by the
RecoveryCallback
upon unsuccessful retry.
ExhaustedRetryException
RetryOperations.execute(RetryCallback, RetryState)
public final <T> T execute(RetryCallback<T> retryCallback, RecoveryCallback<T> recoveryCallback) throws Exception
RetryOperations
RetryCallback
with a fallback on exhausted
retry to the RecoveryCallback
. See implementations for
configuration details.
execute
in interface RetryOperations
RetryCallback
upon successful
invocation, and that returned by the RecoveryCallback
otherwise.
Exception
- any Exception
raised by the
RecoveryCallback
upon unsuccessful retry.public final <T> T execute(RetryCallback<T> retryCallback, RetryState retryState) throws Exception, ExhaustedRetryException
RetryOperations
RetryCallback
with
a target object for the attempt identified by the DefaultRetryState
.
Exceptions thrown by the callback are always propagated immediately so
the state is required to be able to identify the previous attempt, if
there is one - hence the state is required. Normal patterns would see
this method being used inside a transaction, where the callback might
invalidate the transaction if it fails.
execute
in interface RetryOperations
RetryCallback
upon successful
invocation, and that returned by the RecoveryCallback
otherwise.
Exception
- any Exception
raised by the
RecoveryCallback
.
ExhaustedRetryException
- if the last attempt for this state has
already been reachedpublic final <T> T execute(RetryCallback<T> retryCallback) throws Exception
RetryOperations
RetryCallback
with the configured retry
semantics. See implementations for configuration details.
execute
in interface RetryOperations
RetryCallback
upon successful
invocation.
Exception
- any Exception
raised by the
RetryCallback
upon unsuccessful retry.public static List<RetryState> createState(List<?> keys)
public static List<RetryState> createState(List<?> keys, Classifier<? super Throwable,Boolean> classifier)
public void registerListener(RetryListener listener)
public void setBackOffPolicy(BackOffPolicy backOffPolicy)
public void setListeners(RetryListener[] listeners)
public void setRetryContextCache(RetryContextCache retryContextCache)
public void setRetryPolicy(RetryPolicy retryPolicy)
public boolean canRetry(RetryContext context)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |