Scrivio Interview library
ScenarioIntermediate5 min read · updated 12 November 2026

A developer sets a TaskExecutor on the bean named applicationEventMulticaster so that all events are asynchronous. What breaks, and what would you recommend instead?

Setting an executor on the applicationEventMulticaster makes almost every listener in the application asynchronous, including framework listeners, which silently changes semantics everywhere: listeners stop joining the publisher's transaction, their exceptions no longer abort it, and ordering between listeners is lost because they run concurrently. Since Spring 6.1, transactional event listeners opt out and stay bound to the transaction, but the rest change. The better approach is @Async on the specific listeners that need it, with a dedicated bounded executor whose queue and rejection policy are monitored.

Why this question is asked

Making all events asynchronous with one bean definition sounds efficient: no more slow listeners holding up requests. The problem is that this one change alters the behaviour of every listener the application has, including ones written by other teams and by Spring itself, and none of the breakage is reported at startup. Interviewers ask this scenario to see whether we can predict the consequences of a global change. In this answer, we will see what the change does internally, go through what breaks one case at a time, note what newer Spring versions protect, and then set up the targeted alternative.

1What the Change Does

The application context looks for a bean named applicationEventMulticaster and uses it to deliver all events. Defining one with a task executor looks like this.

Java
@Bean(name = "applicationEventMulticaster")
ApplicationEventMulticaster multicaster(TaskExecutor executor) {
var m = new SimpleApplicationEventMulticaster();
m.setTaskExecutor(executor); // every event to every listener now goes through the executor
return m;
}

From now on, for each event and each matching listener, the multicaster submits the call to the executor instead of running it on the publisher's thread, unless the listener reports that it does not support asynchronous execution. Notice that this covers every listener in the context, not just ours: Spring's own listeners, those from Boot and from libraries, and every @EventListener method.

2What Breaks: Transactions and Failure Handling

Some listeners were written to run inside the publisher's transaction. A synchronous listener that updates a stock count when an order is placed relied on joining the order's transaction, so both committed or rolled back together. On an executor thread there is no transaction; the stock update commits on its own, possibly before the order commits, and stays committed if the order rolls back.

Other listeners were written to stop the publisher. A validation listener that throws to reject an invalid order used to abort publishEvent() and roll the transaction back. Now its exception happens on another thread, is handed to the executor or the multicaster's error handler, and the invalid order commits. Nothing fails at startup; the tests that would catch this are the ones checking rollbacks, which are often missing.

Before and after a global executor
BehaviourSynchronous multicasterMulticaster with executor
Listener shares the publisher's transactionyesno
Listener exception aborts the publisheryesno, it is handled on another thread
Listeners run in @Order orderyesno, they run concurrently
MDC and security context availableyesno, unless copied
Transactional listeners (Spring 6.1+)after the phaseunchanged: they opt out
Every row that changes is a silent behaviour change for code nobody touched.

3What Breaks: Ordering

With a synchronous multicaster, listeners run one after another in their @Order sequence. A listener with order 1 that reserves stock finishes before the listener with order 2 that sends a confirmation mentioning the reservation. With an executor, both are submitted at once and may run on two threads at the same time. Order 2 can finish first, and @Order no longer means anything for these listeners. Any code that quietly depended on order, which is common, now has a race condition that appears only under load.

4What Newer Spring Versions Protect

Older advice says that a global executor also breaks @TransactionalEventListener, because the listener would run on a thread without a transaction and drop the event. Since Spring Framework 6.1, listeners can declare whether they support asynchronous execution, and transactional event listeners return false, so the multicaster calls them on the publishing thread and they still register with the transaction. Their target method can still be made asynchronous with @Async. On older versions, check this carefully, because the event may simply be lost.

Two other details are worth knowing. If the executor rejects a task, for example during shutdown, the multicaster runs the listener on the calling thread instead, so behaviour differs between normal running and shutdown. And framework events published while the context closes are also delivered through the executor, which may already be shutting down.

5The Targeted Alternative

The better approach keeps the default synchronous multicaster and makes only the listeners that need it asynchronous, with an executor sized for that work.

Java
@Configuration
@EnableAsync
class ListenerExecutors {
@Bean
ThreadPoolTaskExecutor notificationExecutor() {
var ex = new ThreadPoolTaskExecutor();
ex.setCorePoolSize(4);
ex.setMaxPoolSize(8);
ex.setQueueCapacity(500); // bounded: a burst cannot exhaust memory
ex.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); // back-pressure
ex.setThreadNamePrefix("notify-");
return ex;
}
}
@Async("notificationExecutor")
@TransactionalEventListener
void sendConfirmation(OrderPlaced e) { ... } // only this listener is asynchronous

Notice the bounded queue and the rejection policy. An unbounded queue hides a slow downstream service until memory runs out; a bounded queue with CallerRunsPolicy slows the publisher a little instead, which is visible and safe, while a discard policy would drop work silently. We also monitor the executor: active threads, queue size and rejected tasks, which a ThreadPoolTaskExecutor bean exposes through Micrometer in Spring Boot. Finally, each asynchronous listener is a deliberate decision that its author has reviewed for transaction, error and context assumptions.

6Follow-up questions

Is there ever a good reason for a global executor on the multicaster?

Rarely. It can make sense in a small application whose events are all fire-and-forget notifications written by one team that knows every listener. Even then, @Async on those listeners gives the same benefit without affecting framework listeners or future code.

How would you find listeners that depended on synchronous behaviour before removing the global executor?

Search for listeners that use repositories or throw exceptions, and for @Order on listener methods, since those are the ones relying on transactions, failure propagation or ordering. Tests that publish an event and then assert rollback or ordering confirm each case.

What does an ErrorHandler on the multicaster do in this setup?

It catches exceptions thrown by listeners and handles them, for example by logging. With an executor it runs on the executor thread, so it is a place to record failures, but it cannot give the publisher back the ability to react to them.

7Conclusion

In this answer, we saw that a task executor on the applicationEventMulticaster makes nearly every listener asynchronous, including framework listeners. Listeners stop sharing the publisher's transaction, their exceptions no longer abort it, and @Order is lost because listeners run concurrently; since Spring 6.1, transactional event listeners opt out, which older versions did not. The better choice is @Async on the specific listeners that need it, with a dedicated bounded executor, an explicit rejection policy and monitoring of its queue.

What to say in the interviewAbout 90 seconds aloud

Open with

Setting an executor on the applicationEventMulticaster is a global change: from then on almost every listener in the context runs on the executor, including Spring's and libraries' listeners, not just the slow one the developer had in mind.

Then, if they want more

Several things break silently. Listeners that relied on joining the publisher's transaction now commit on their own, even if the publisher rolls back. Listeners that threw to abort an operation no longer stop it, because the exception happens on another thread.

Ordering is lost, because listeners with @Order 1 and 2 are submitted together and run concurrently, so any hidden dependency between them becomes a race. MDC and security context are gone on those threads too.

One nuance: since Spring 6.1, transactional event listeners report that they do not support async execution, so the multicaster still calls them on the publishing thread; on older versions they could lose events. My recommendation is to keep the default synchronous multicaster and put @Async on the specific listeners that should not block the publisher, with a dedicated executor.

I would bound its queue, pick a rejection policy like CallerRunsPolicy so a burst slows the publisher instead of exhausting memory or dropping work, and monitor active threads, queue size and rejections. Each async listener is then a deliberate decision.

About this answer

Last updated
12 November 2026
Versions it names
Spring Framework 6
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "A developer sets a TaskExecutor on the bean named applicationEventMulticaster so that...": https://scrivio-interview-library.netlify.app/spring-boot/spring-events/4f9ae0a73f/