Spring @Async or EJB @Asynchronous for an asynchronous service call?

I am working on a project using Hibernate JPA and Spring MVC, I am studying the implementation of an asynchronous service, and I realized that I am getting two annotations @Async or @Asynchronous from Spring and EJB.

Everything here is quite new for me, and I would go to EJB @Asynchronous and see how this happens, I was wondering if one solution has an advantage over another?

+4
source share
1 answer

@Async and @Asynchronous identical in their capabilities. They both run this method in a separate thread pool, and both enable the result type void and Future<T> . There are no functional differences between them. Spring's only (minor) advantage is that you have full control over the lower thread pool, and with @Asynchronous this is probably configured based on the container.

If your application already uses Spring MVC, @Async seems like a natural consequence.

+5
source

All Articles