The @Async annotation lets a Spring event listener run on a separate thread, so the code that published the event does not wait for the listener to finish. By default Spring delivers application events synchronously on the publisher's thread, so a slow listener blocks the publisher. Add @EnableAsync to a configuration class and put @Async on the listener method to move the work to an executor.
This matters for slow side effects such as sending email, calling external APIs or writing audit records, where the caller does not need the result.
When you call ApplicationEventPublisher.publishEvent(...), Spring invokes every matching listener in the publishing thread, one after another. Consequences of the synchronous default:
That behaviour is predictable, which is why it is the default. Asynchronous handling is something you opt into per listener.
You need three pieces: an event type, a listener marked @Async, and @EnableAsync.
Typical output:
The publisher returns immediately and the listener runs on an executor thread. In Spring Boot 3.2+ with virtual threads enabled (spring.threads.virtual.enabled=true) the auto-configured task executor uses virtual threads.
If no executor bean is defined, Spring Boot auto-configures a ThreadPoolTaskExecutor named applicationTaskExecutor. Without Boot, Spring falls back to SimpleAsyncTaskExecutor, which starts a new thread per task and does not pool them. For production, define your own bounded pool:
Select it on the listener with @Async("eventExecutor"). A bounded queue protects the application: when it is full, the default policy rejects tasks, so choose capacity deliberately.
Three pitfalls come up often.
void async method cannot throw back to the caller. Register an AsyncUncaughtExceptionHandler by implementing AsyncConfigurer, or catch and log inside the listener.@TransactionalEventListener (default phase AFTER_COMMIT) together with @Async.@Async works through a proxy, so calling the listener method from within the same class bypasses it, and the method must not be private.Note that a transactional event listener that is also async should not rely on the original transaction. If it needs to write to the database it should start its own transaction, for example with @Transactional(propagation = Propagation.REQUIRES_NEW) on a service it calls.
| Approach | When to use it |
|---|---|
@Async on @EventListener | Simple, per-listener asynchronous handling |
A custom multicaster with a TaskExecutor | Make every listener asynchronous (a bean named applicationEventMulticaster) |
| A message broker (Kafka, RabbitMQ) | Work must survive restarts or cross service boundaries |
An in-process @Async event is lost if the application stops before the task runs. If the work is important, persist it first or use a broker.
No. They are delivered synchronously on the publishing thread. You make a listener asynchronous with @Async and @EnableAsync.
Usually @EnableAsync is missing, the method is called from within the same class, or the method is not public on a Spring bean.
It can return void, a CompletableFuture, or you can have it return a new event to publish, but the publisher does not wait for it.
Use @TransactionalEventListener, which runs after commit by default, and combine it with @Async if the work should also be off the request thread.
Spring events are synchronous unless you opt out. Add @EnableAsync, annotate the listener with @Async, and give it a bounded executor so slow handlers do not block publishers. Remember that errors and transactions do not cross the thread boundary, and use a broker when the work must not be lost.