注释类型 TransactionalEventListener
@Target({METHOD,ANNOTATION_TYPE}) @Retention(RUNTIME) @Documented @EventListener public @interface TransactionalEventListener
AnEventListener
that is invoked according to aTransactionPhase
.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 itsTransactionPhase
.Adding
@Order
to your annotated method allows you to prioritize that listener amongst other listeners running before or after transaction completion.- 从以下版本开始:
- 4.2
- 作者:
- Stephane Nicoll, Sam Brannen
可选元素概要
可选元素 修饰符和类型 可选元素 说明 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 forclasses()
.
元素详细资料
phase
TransactionPhase phase
Phase to bind the handling of an event to.The default phase is
TransactionPhase.AFTER_COMMIT
.If no transaction is in progress, the event is not processed at all unless
fallbackExecution()
has been enabled explicitly.- 默认值:
- org.springframework.transaction.event.TransactionPhase.AFTER_COMMIT
fallbackExecution
boolean fallbackExecution
Whether the event should be processed if no transaction is running.- 默认值:
- false
value
@AliasFor(annotation=EventListener.class, attribute="classes") Class<?>[] value
Alias forclasses()
.- 默认值:
- {}
classes
@AliasFor(annotation=EventListener.class, attribute="classes") Class<?>[] classes
The 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.
- 默认值:
- {}