Affects: Spring Boot 2.2.0.M3
If we publish the events within the transactional reactive methods, for example:
@Transactional
public Mono<Model> create(Model model, ModelEvent.Type type) {
return repo.save(model)
.doOnSuccess(m -> publisher.publishEvent(new ModelEvent(m, type)));
}
then the 'event listener' method with @TransactionalEventListener
is not invoked (regardless of whether the @Async
annotation is used or not):
// @Async
@TransactionalEventListener(condition = "#event.inTransactionEventListener()")
public void handleEventInTransactionEventListener(ModelEvent event) {
log.info("[i] Handled event: {}, in transactional event listener", event.getModel());
}
Related demo is here.
Comment From: cwiejack
Hi, any updates on this issue? I'm having this problem with Spring Boot 2.4.0-RC1
Comment From: snicoll
Thanks for the nudge and sorry this wasn't triaged earlier. @TransactionalEvenListener
only works with imperative transactions, not reactive transaction so we'll have to clarify that in the reference guide and, potentially, the javadoc of related classes.
Comment From: cwiejack
Hi, thank you for clarification.
Comment From: pkgonan
@snicoll Hi. Is there any plan to support TransactionalEventListener for Reactive ? (like @ReactiveTransactionalEventListener).
Comment From: snicoll
I am afraid not.
Comment From: jhoeller
As a documentation ticket, this duplicates #25805.
Comment From: jhoeller
As of 6.1, @TransactionalEventListener
can be triggered with reactive transactions through adding the transaction context as the event source: https://github.com/spring-projects/spring-framework/issues/27515#issuecomment-1660934318