Package org.springframework.retry
Interface RetryOperations
- All Known Implementing Classes:
RetryTemplate
public interface RetryOperations
Defines the basic set of operations implemented by
RetryOperations
to execute
operations with configurable retry behaviour.- Author:
- Rob Harrop, Dave Syer
-
Method Summary
Modifier and TypeMethodDescription<T,
E extends Throwable>
Texecute
(RetryCallback<T, E> retryCallback) Execute the suppliedRetryCallback
with the configured retry semantics.<T,
E extends Throwable>
Texecute
(RetryCallback<T, E> retryCallback, RecoveryCallback<T> recoveryCallback) Execute the suppliedRetryCallback
with a fallback on exhausted retry to theRecoveryCallback
.<T,
E extends Throwable>
Texecute
(RetryCallback<T, E> retryCallback, RecoveryCallback<T> recoveryCallback, RetryState retryState) A stateful retry with a recovery path.<T,
E extends Throwable>
Texecute
(RetryCallback<T, E> retryCallback, RetryState retryState) A simple stateful retry.
-
Method Details
-
execute
Execute the suppliedRetryCallback
with the configured retry semantics. See implementations for configuration details.- Type Parameters:
T
- the return valueE
- the exception to throw- Parameters:
retryCallback
- theRetryCallback
- Returns:
- the value returned by the
RetryCallback
upon successful invocation. - Throws:
E
- anyException
raised by theRetryCallback
upon unsuccessful retry.E
- the exception thrown
-
execute
<T,E extends Throwable> T execute(RetryCallback<T, E> retryCallback, RecoveryCallback<T> recoveryCallback) throws EExecute the suppliedRetryCallback
with a fallback on exhausted retry to theRecoveryCallback
. See implementations for configuration details.- Type Parameters:
T
- the type to returnE
- the type of the exception- Parameters:
recoveryCallback
- theRecoveryCallback
retryCallback
- theRetryCallback
RecoveryCallback
upon- Returns:
- the value returned by the
RetryCallback
upon successful invocation, and that returned by theRecoveryCallback
otherwise. - Throws:
E
- anyException
raised by the unsuccessful retry.
-
execute
<T,E extends Throwable> T execute(RetryCallback<T, E> retryCallback, RetryState retryState) throws E, ExhaustedRetryExceptionA simple stateful retry. Execute the suppliedRetryCallback
with a target object for the attempt identified by theDefaultRetryState
. 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. See implementations for configuration details.- Type Parameters:
T
- the type of the return valueE
- the type of the exception to return- Parameters:
retryCallback
- theRetryCallback
retryState
- theRetryState
- Returns:
- the value returned by the
RetryCallback
upon successful invocation, and that returned by theRecoveryCallback
otherwise. - Throws:
E
- anyException
raised by theRecoveryCallback
.ExhaustedRetryException
- if the last attempt for this state has already been reached
-
execute
<T,E extends Throwable> T execute(RetryCallback<T, E> retryCallback, RecoveryCallback<T> recoveryCallback, RetryState retryState) throws EA stateful retry with a recovery path. Execute the suppliedRetryCallback
with a fallback on exhausted retry to theRecoveryCallback
and a target object for the retry attempt identified by theDefaultRetryState
.- Type Parameters:
T
- the return value typeE
- the exception type- Parameters:
recoveryCallback
- theRecoveryCallback
retryState
- theRetryState
retryCallback
- theRetryCallback
- Returns:
- the value returned by the
RetryCallback
upon successful invocation, and that returned by theRecoveryCallback
otherwise. - Throws:
E
- anyException
raised by theRecoveryCallback
upon unsuccessful retry.- See Also:
-