Skip to content

@TransactionalEventListener cannot work with TaskExecutor #25129

Closed
@weaselmetal

Description

@weaselmetal

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: invalidAn issue that we don't feel is valid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions