Description
Affects: Spring 4.2
I came to believe that a @TransactionalEventListener
cannot work with a applicationEventMulticaster
bean that uses a taskExecutor
that invokes the listener call in a new / different thread.
Inside a new thread, which cannot be transaction synchronized in my understanding, the call to the listener will be discarded, unless the @TransactionalEventListener(fallbackExecution = true)
is set. So, proper coupling to a transaction seems to be impossible.
Should you desire a true asynchronous invocation on other event handlers, you will have to provide a task executor that delegates the invocation to different threads.
JavaDoc doesn't indicate that @TransactionalEventListener
cannot work with a non-synchronous task executor in place. But, I might be doing something wrong after all.
As far as I can tell, the code in spring-tx library behaves as it should, but can only work when no task executor is used at all in the event multicaster, or an executor like org.springframework.core.task.SyncTaskExecutor
is used.