Class MethodRollbackEvent
java.lang.Object
java.util.EventObject
org.springframework.context.ApplicationEvent
org.springframework.context.event.MethodFailureEvent
org.springframework.transaction.interceptor.MethodRollbackEvent
- All Implemented Interfaces:
Serializable
Event published for every exception encountered that triggers a transaction rollback
through a proxy-triggered method invocation or a reactive publisher returned from it.
Can be listened to via an
ApplicationListener<MethodRollbackEvent> bean or
an @EventListener(MethodRollbackEvent.class) method.
Note: This event gets published right before the actual transaction rollback.
As a consequence, the exposed transaction reflects the state
of the transaction right before the rollback.
- Since:
- 7.0.3
- Author:
- Juergen Hoeller
- See Also:
-
Field Summary
Fields inherited from class EventObject
source -
Constructor Summary
ConstructorsConstructorDescriptionMethodRollbackEvent(MethodInvocation invocation, Throwable failure, TransactionExecution transaction) Create a new event for the given rolled-back method invocation. -
Method Summary
Modifier and TypeMethodDescriptionReturn the exception encountered.Return the corresponding transaction status.Methods inherited from class MethodFailureEvent
getMethod, getSource, toStringMethods inherited from class ApplicationEvent
getTimestamp
-
Constructor Details
-
MethodRollbackEvent
public MethodRollbackEvent(MethodInvocation invocation, Throwable failure, TransactionExecution transaction) Create a new event for the given rolled-back method invocation.- Parameters:
invocation- the transactional method invocationfailure- the exception encountered that triggered a rollbacktransaction- the transaction status right before the rollback
-
-
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.
- Overrides:
getFailurein classMethodFailureEvent
-
getTransaction
Return the corresponding transaction status.
-