@EventListener @Target(value={METHOD,ANNOTATION_TYPE}) @Retention(value=RUNTIME) @Documented public @interface TransactionalEventListener
EventListener that is invoked according to a TransactionPhase.
If the event is not published within the boundaries of a managed transaction, the event
is discarded unless the fallbackExecution() flag is explicitly set. If a
transaction is running, the event is processed according to its TransactionPhase.
Adding @Order on your annotated method
allows you to prioritize that listener amongst other listeners running in the same phase.
| Modifier and Type | Optional Element and Description |
|---|---|
Class<?>[] |
classes
The event classes that this listener handles.
|
String |
condition
Spring Expression Language (SpEL) attribute used for making the event
handling conditional.
|
boolean |
fallbackExecution
Whether the event should be processed if no transaction is running.
|
TransactionPhase |
phase
Phase to bind the handling of an event to.
|
Class<?>[] |
value
Alias for
classes(). |
public abstract TransactionPhase phase
If no transaction is in progress, the event is not processed at
all unless fallbackExecution() has been enabled explicitly.
public abstract boolean fallbackExecution
@AliasFor(value="value") public abstract Class<?>[] classes
When this attribute is specified with one value, the method parameter may or may not be specified. When this attribute is specified with more than one value, the method must not have a parameter.
public abstract String condition
Default is "", meaning the event is always handled.
EventListener.condition()