Skip to main content

Async Events, Transactional Events, Custom Multicaster and Best Practices

Learn Async Events, Transactional Events, Custom Multicaster and Best Practices (Phase 9 · Spring Events (Core), Spring Core) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Asynchronous events • Add @Async to a listener (with @EnableAsync ) to run it on a TaskExecutor ; or configure the multicaster with an executor to make all listeners async. Trade-offs: the publisher no longer waits, exceptions are not propagated (use AsyncUncaughtExceptionHandler ), the listener runs outside the publisher's transaction and security context , and ordering is lost. Use a bounded ThreadPoolTaskExecutor (or virtual threads) so a burst of events cannot exhaust resources.

More lessons in Phase 9 · Spring Events (Core)