Class CompositeRetryListener
java.lang.Object
org.springframework.core.retry.support.CompositeRetryListener
- All Implemented Interfaces:
RetryListener
A composite implementation of the
RetryListener interface, which is
used to compose multiple listeners within a
RetryTemplate.
Delegate listeners will be called in their registration order.
- Since:
- 7.0
- Author:
- Mahmoud Ben Hassine, Juergen Hoeller, Sam Brannen
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a newCompositeRetryListener.CompositeRetryListener(List<RetryListener> listeners) Create a newCompositeRetryListenerwith the supplied list of delegates. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(RetryListener listener) Add a new listener to the list of delegates.voidbeforeRetry(RetryPolicy retryPolicy, Retryable<?> retryable) Called before every retry attempt.voidonRetryFailure(RetryPolicy retryPolicy, Retryable<?> retryable, Throwable throwable) Called after every failed retry attempt.voidonRetryPolicyExhaustion(RetryPolicy retryPolicy, Retryable<?> retryable, RetryException exception) Called if theRetryPolicyis exhausted.voidonRetryPolicyInterruption(RetryPolicy retryPolicy, Retryable<?> retryable, RetryException exception) Called if theRetryPolicyis interrupted between retry attempts.voidonRetrySuccess(RetryPolicy retryPolicy, Retryable<?> retryable, @Nullable Object result) Called after the first successful retry attempt.
-
Constructor Details
-
CompositeRetryListener
public CompositeRetryListener()Create a newCompositeRetryListener.- See Also:
-
CompositeRetryListener
Create a newCompositeRetryListenerwith the supplied list of delegates.- Parameters:
listeners- the list of delegate listeners to register; must not be empty
-
-
Method Details
-
addListener
Add a new listener to the list of delegates.- Parameters:
listener- the listener to add
-
beforeRetry
Description copied from interface:RetryListenerCalled before every retry attempt.- Specified by:
beforeRetryin interfaceRetryListener- Parameters:
retryPolicy- theRetryPolicyretryable- theRetryableoperation
-
onRetrySuccess
public void onRetrySuccess(RetryPolicy retryPolicy, Retryable<?> retryable, @Nullable Object result) Description copied from interface:RetryListenerCalled after the first successful retry attempt.- Specified by:
onRetrySuccessin interfaceRetryListener- Parameters:
retryPolicy- theRetryPolicyretryable- theRetryableoperationresult- the result of theRetryableoperation
-
onRetryFailure
Description copied from interface:RetryListenerCalled after every failed retry attempt.- Specified by:
onRetryFailurein interfaceRetryListener- Parameters:
retryPolicy- theRetryPolicyretryable- theRetryableoperationthrowable- the exception thrown by theRetryableoperation
-
onRetryPolicyExhaustion
public void onRetryPolicyExhaustion(RetryPolicy retryPolicy, Retryable<?> retryable, RetryException exception) Description copied from interface:RetryListenerCalled if theRetryPolicyis exhausted.- Specified by:
onRetryPolicyExhaustionin interfaceRetryListener- Parameters:
retryPolicy- theRetryPolicyretryable- theRetryableoperationexception- the resultingRetryException, with the last exception thrown by theRetryableoperation as the cause and any exceptions from previous attempts as suppressed exceptions- See Also:
-
onRetryPolicyInterruption
public void onRetryPolicyInterruption(RetryPolicy retryPolicy, Retryable<?> retryable, RetryException exception) Description copied from interface:RetryListenerCalled if theRetryPolicyis interrupted between retry attempts.- Specified by:
onRetryPolicyInterruptionin interfaceRetryListener- Parameters:
retryPolicy- theRetryPolicyretryable- theRetryableoperationexception- the resultingRetryException, with anInterruptedExceptionas the cause and any exceptions from previous invocations of theRetryableoperation as suppressed exceptions- See Also:
-