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 suppliedRetryCallbackwith the configured retry semantics.<T,E extends Throwable>
Texecute(RetryCallback<T, E> retryCallback, RecoveryCallback<T> recoveryCallback) Execute the suppliedRetryCallbackwith 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 suppliedRetryCallbackwith 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
RetryCallbackupon successful invocation. - Throws:
E- anyExceptionraised by theRetryCallbackupon unsuccessful retry.E- the exception thrown
-
execute
<T,E extends Throwable> T execute(RetryCallback<T, E> retryCallback, RecoveryCallback<T> recoveryCallback) throws EExecute the suppliedRetryCallbackwith 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- theRecoveryCallbackretryCallback- theRetryCallbackRecoveryCallbackupon- Returns:
- the value returned by the
RetryCallbackupon successful invocation, and that returned by theRecoveryCallbackotherwise. - Throws:
E- anyExceptionraised 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 suppliedRetryCallbackwith 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- theRetryCallbackretryState- theRetryState- Returns:
- the value returned by the
RetryCallbackupon successful invocation, and that returned by theRecoveryCallbackotherwise. - Throws:
E- anyExceptionraised 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 suppliedRetryCallbackwith a fallback on exhausted retry to theRecoveryCallbackand a target object for the retry attempt identified by theDefaultRetryState.- Type Parameters:
T- the return value typeE- the exception type- Parameters:
recoveryCallback- theRecoveryCallbackretryState- theRetryStateretryCallback- theRetryCallback- Returns:
- the value returned by the
RetryCallbackupon successful invocation, and that returned by theRecoveryCallbackotherwise. - Throws:
E- anyExceptionraised by theRecoveryCallbackupon unsuccessful retry.- See Also:
-