Interface RetryOperations
- All Known Implementing Classes:
RetryTemplate
public interface RetryOperations
Interface specifying basic retry operations.
Implemented by RetryTemplate. Not often used directly, but a useful
option to enhance testability, as it can easily be mocked or stubbed.
Inspired by the Spring Retry project but redesigned as a minimal core retry feature in the Spring Framework.
- Since:
- 7.0
- Author:
- Mahmoud Ben Hassine, Juergen Hoeller
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionExecute the givenRetryableoperation according to theRetryPolicyconfigured at the implementation level.voidInvoke the givenRunnableaccording to theRetryPolicy, returning successfully or throwing the lastRunnableexception to the caller in case of retry policy exhaustion.Invoke the givenSupplieraccording to theRetryPolicy, returning a successful result or throwing the lastSupplierexception to the caller in case of retry policy exhaustion.
-
Method Details
-
execute
Execute the givenRetryableoperation according to theRetryPolicyconfigured at the implementation level.If the
Retryablesucceeds, its result will be returned. Otherwise, aRetryExceptionwill be thrown to the caller. TheRetryExceptionwill contain the last exception thrown by theRetryableoperation as the cause and any exceptions from previous attempts as suppressed exceptions.- Type Parameters:
R- the type of the result- Parameters:
retryable- theRetryableto execute and retry if needed- Returns:
- the successful result of the
Retryable, if any - Throws:
RetryException- if theRetryPolicyis exhausted. Note that this exception represents a failure outcome and is not meant to be propagated; you will typically rather rethrow its cause (the last original exception thrown by theRetryablecallback) or throw a custom business exception instead.
-
invoke
Invoke the givenSupplieraccording to theRetryPolicy, returning a successful result or throwing the lastSupplierexception to the caller in case of retry policy exhaustion.- Type Parameters:
R- the type of the result- Parameters:
retryable- theSupplierto invoke and retry if needed- Returns:
- the result of the
Supplier - Throws:
RuntimeException- if thrown by theSupplier- Since:
- 7.0.3
-
invoke
Invoke the givenRunnableaccording to theRetryPolicy, returning successfully or throwing the lastRunnableexception to the caller in case of retry policy exhaustion.- Parameters:
retryable- theRunnableto invoke and retry if needed- Throws:
RuntimeException- if thrown by theRunnable- Since:
- 7.0.3
-