Java @Async
In this article, we’ll explore the asynchronous execution support in Spring – and the @Async annotation. Simply put – annotating a method of a bean with @Async will make it execute in a separate thread i.e. the caller will not wait for the completion of the called method. Enable Async Support Let’s start by enabling asynchronous processing with Java configuration – by simply adding the @EnableAsync to a configuration class: @Configuration @EnableAsync public class SpringAsyncConfig { ... } The enable annotation is enough, but as you’d expect, there are also a few simple options for configuration as well: annotation – b y default, @EnableAsync detects Spring’s @Async annotation and the EJB 3.1 javax.ejb.Asynchronous ; this option can be used to detect other, user-defined annotation types as well mode – indicates the type of advice that should be used – JDK proxy-based or AspectJ weaving proxyTargetClass – indicates the type of proxy that sho...