I am working on a project using Hibernate JPA and Spring MVC, I am looking into implementing an asynchronous service, and I realized that I am getting the two annotations @Async or @Asynchronous from repectively Spring and EJB.
Everything here is pretty new for me, and I would go for the EJB @Asynchronous and see how it goes, I was wondering if one solution has an advantage over the other?
@Async
and @Asynchronous
are identical in their capabilities. They both run given method in a separate thread pool and they both allow void
and Future<T>
result type. There is no functional different between them. The only (minor) advantage of Spring is that you have full control over underlying thread pool while with @Asynchronous
this is probably configured on a container-specific basis.
If your application already uses Spring MVC, @Async
seems like a natural consequence.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With