Class MethodRetryEvent
java.lang.Object
java.util.EventObject
org.springframework.context.ApplicationEvent
org.springframework.context.event.MethodFailureEvent
org.springframework.resilience.retry.MethodRetryEvent
- All Implemented Interfaces:
Serializable
Event published for every exception encountered during retryable method invocation.
Can be listened to via an
ApplicationListener<MethodRetryEvent> bean or an
@EventListener(MethodRetryEvent.class) method.- Since:
- 7.0.3
- Author:
- Juergen Hoeller
- See Also:
-
Field Summary
Fields inherited from class EventObject
source -
Constructor Summary
ConstructorsConstructorDescriptionMethodRetryEvent(MethodInvocation invocation, Throwable failure, boolean retryAborted) Create a new event for the given retryable method invocation. -
Method Summary
Modifier and TypeMethodDescriptionReturn the exception encountered.booleanReturn whether the current failure led to the retry execution getting aborted, typically indicating exhaustion, interruption or a timeout scenario.toString()Methods inherited from class MethodFailureEvent
getMethod, getSourceMethods inherited from class ApplicationEvent
getTimestamp
-
Constructor Details
-
MethodRetryEvent
Create a new event for the given retryable method invocation.- Parameters:
invocation- the retryable method invocationfailure- the exception encounteredretryAborted- whether the current failure led to the retry execution getting aborted
-
-
Method Details
-
getFailure
Return the exception encountered.This may be an exception thrown by the method or emitted by the reactive publisher returned from the method, or a terminal exception on retry exhaustion, interruption or timeout.
For
RetryTemplateexecutions, aninstanceof RetryExceptioncheck identifies a final exception. For Reactor pipelines,Exceptions.isRetryExhaustedidentifies an exhaustion exception, whereasinstanceof TimeoutExceptionreveals a timeout scenario.- Overrides:
getFailurein classMethodFailureEvent- See Also:
-
isRetryAborted
public boolean isRetryAborted()Return whether the current failure led to the retry execution getting aborted, typically indicating exhaustion, interruption or a timeout scenario.If this returns
true,getFailure()exposes the final exception thrown by the retry infrastructure (rather than thrown by the method itself).- See Also:
-
toString
- Overrides:
toStringin classMethodFailureEvent
-