Asynchronous session beans and 'Concurrency Utilities for Java EE API'

Written on December 2, 2013

t’s true hard work never killed anybody, but I figure, why take the chance?

Ronald Reagan

There are different approaches to obtain an asynchronous behaviour within a Java EE application, this post cover 2 of them.

Asynchronous Session Beans, added in EJB 3.1 (Java EE 6), is one possible solution. The @Asynchronous annotation is used to decorate session bean methods that should be invoked asynchronously. When such a bean method is invoked, the control returns to the invoking client before the container dispatches the invocation to an instance of the bean. This allows the client to continue processing in parallel while that particular session bean method performs its operations. In EJB 3.2 (Java EE 7), Asynchronous Session Beans are now part of EJB Lite and as such are even more widely available.

Another approach is the use the new Concurrency Utilities for Java EE API (JSR 236) which was added to Java EE 7. The goal of this JSR is simple, i.e. it allows to safely use some of Java SE’s java.util.concurrent.* features within a Java EE context. So if you are familiar with some the JSR166 features (e.g. ExecutorServices), you can now re-use the same features in a managed Java EE environment.

Mohamed Sanaulla recently wrote different posts explaining how to use the different JSR 236 Managed Objects : ManagedExecutorService, ManagedScheduledExecutorService and ManagedThreadFactory.

Originaly posted on The Aquarium blog.