Annotation Interface TransactionalEventListener
EventListenerthat is invoked according to a
TransactionPhase. This is an annotation-based equivalent of
If the event is not published within an active transaction, the event is discarded
fallbackExecution() flag is explicitly set. If a transaction is
running, the event is handled according to its
@Order to your annotated
method allows you to prioritize that listener amongst other listeners running before
or after transaction completion.
NOTE: Transactional event listeners only work with thread-bound transactions
managed by a
PlatformTransactionManager. A reactive transaction managed by a
uses the Reactor context instead of thread-local variables, so from the perspective of
an event listener, there is no compatible active transaction that it can participate in.
WARNING: if the
TransactionPhase is set to
AFTER_COMMIT (the default),
AFTER_COMPLETION, the transaction will
have been committed or rolled back already, but the transactional resources might
still be active and accessible. As a consequence, any data access code triggered
at this point will still "participate" in the original transaction, but changes
will not be committed to the transactional resource. See
TransactionSynchronization.afterCompletion(int) for details.
Optional Element SummaryModifier and TypeOptional ElementDescription
Class<?>The event classes that this listener handles.Spring Expression Language (SpEL) attribute used for making the event handling conditional.
booleanWhether the event should be handled if no transaction is running.An optional identifier for the listener, defaulting to the fully-qualified signature of the declaring method (e.g.Phase to bind the handling of an event to.
phaseTransactionPhase phasePhase to bind the handling of an event to.
The default phase is
If no transaction is in progress, the event is not processed at all unless
fallbackExecution()has been enabled explicitly.
fallbackExecutionboolean fallbackExecutionWhether the event should be handled if no transaction is running.
classesThe event classes that this listener handles.
If this attribute is specified with a single value, the annotated method may optionally accept a single parameter. However, if this attribute is specified with multiple values, the annotated method must not declare any parameters.
conditionSpring Expression Language (SpEL) attribute used for making the event handling conditional.
The default is
"", meaning the event is always handled.
- See Also:
idAn optional identifier for the listener, defaulting to the fully-qualified signature of the declaring method (e.g. "mypackage.MyClass.myMethod()").