Monday Dec 02, 2013

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

"It'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.

Thursday Sep 12, 2013

Asynchronous Servlets and Java EE Concurrency Utilities

As many of you might already be aware, one of the key changes in Servlet 3/Java EE 6 was the introduction of asynchronous Servlets. Interestingly enough, a lot of the code examples at the time used native Java SE concurrency APIs to demonstrate the asynchronous Servlets feature. The problem in a Java EE environment is that Java SE concurrency essentially bypasses the Java EE runtime altogether and misses valuable contextual information (security, class-loader, naming, etc), not to mention potentially compromising stability/scalability since it sidesteps the container's internal thread/resource pools. Native Java SE threads also can't be managed or monitored via the application server (such as providing admin console visualizations, automatic timeouts, long-running warnings, etc). This of course is where the Java EE concurrency utilities standardized in Java EE 7 comes in. In a recent code-driven blog post, Shing Wai Chan demonstrates how to properly use asynchronous Servlets via the Java EE concurrency utilities.

For those that aren't big fans of lower level concurrency APIs (I sympathize :-)), it is certainly possible to use asynchronous Servlets with EJB 3 @Asynchronous instead as demonstrated here.

Tuesday Aug 13, 2013

Using Java EE Concurrency Utilities Executor Service

Java EE Concurrency Utilities (more formally Concurrency Utilities for the Java EE Platform) fills an important and long standing gap for Java EE 7. The API empowers you to use util.concurrent style low-level/advanced concurrency features inside a Java EE runtime in a vendor-neutral, secure, predictable and reliable fashion. In this brief blog post, German author, JCP expert group member and key Java EE advocate Adam Bien demonstrates using one of the most useful Concurrency Utility features - the managed executor service. There's also the 20-minute Concurrency Utilities presentation by specification lead Anthony Lai on the GlassFish videos YouTube channel and the slide deck from my own lightning talk:

You can also check out the very well written Java EE Concurrency Utilities section of the official Java EE 7 tutorial or try things out with the newly released Java EE 7 SDK.

Friday May 10, 2013

Java EE@JavaOne Russia 2013

JavaOne Russia 2013 was held at the Crocus Expo Center in Moscow on April 23-24. The conference was a resounding success with a great vibe, excellent technical content and numerous world class speakers. Some notable speakers included Werner Keil, Joonas Lehtinen, Heather VanCura, Paul Bakker, Bert Ertman, Talip Ozturk, Anil Gaur, Geertjan Wielenga, Arun Gupta, Jim Weaver, Stephen Chin and David Delabassee. Topics covered included the JCP/JUGs, Java SE 8, Java EE 7, HTML 5/WebSocket, JSF, JMS 2, JAX-RS 2, Java EE Concurrency, JBatch, JSON-P, NetBeans, MySQL, Vaadin, the Oracle Java Cloud, OpenShift, OSGi, JavaFX and Coherence.

 

 

I delivered the Java EE technical keynote, two technical sessions (one on JSM 2 and the other on JAX-RS 2) and three lighting talks (on Java EE Concurrency, JBatch and JSON-P). I also helped deliver two hands-on-labs (on Java EE 7 and the Java Cloud Service). More details on the sessions and JavaOne Russia 2013, including the slide decks and code, posted on my personal blog.

Tuesday Apr 30, 2013

Anthony Lai on Java EE Concurrency Utilities

The 129th episode of the Java Spotlight podcast features an interview with Java EE Concurrency Utilities (JSR 236) spec lead Anthony Lai. As you may be aware, the Java EE Concurrency Utilities has been a long awaited and very important foundational API, especially for third party vendors to more easily integrate with the underlying application server runtime. Anthony talks with Roger Brinkley about the motivation for the JSR, it's long history, some of the API details, current status and the future.

You can listen to the full podcast here. It's really a great starting point for learning about the Java EE Concurrency Utilities. You can certainly give the proposed final draft a read yourself (the API recently passed it's final approval ballot). At fifty some pages, it is a very digestible specification. You can also try the API out with a GlassFish promoted build.

Monday Jan 14, 2013

Java EE 7 in Public Review!

Java EE 7 has turned the last lap and is racing towards the finish line! The Java EE 7 JSR itself (JSR 342) very recently published it's official Public Review Draft. The review closes on February 11th so act fast, read the draft spec and send your feedback. The draft is available here. After the review is over, the JSR will go to the EC ballot.

And Java EE 7 is not the only one. As this JSR update from the JCP indicates, the review periods for JMS 2, Java EE Concurrency, WebSocket, JPA 2.1 and JSON-P are still open but will be coming to an end rapidly in the next few weeks.

Thursday Dec 13, 2012

Great Java EE Concurrency Write-up!

As you are aware JSR-236, Concurrency Utilities for the Java EE platform, is now a candidate for addition into Java EE 7. While it is a critical enabling API it is not necessarily obvious why it is so important. This is especially true with existing features like EJB 3 @Asynchronous, Servlet 3 async and JAX-RS 2 async. On his blog DZone MVB Sander Mak does an excellent job of explaining the motivation and importance of JSR-236.

Perhaps even more importantly, he discusses potential issues with the API such alignment with CDI and Java SE Fork/Join. Read the excellent write-up here!

Tuesday Nov 20, 2012

Concurrency Utilities for Java EE (JSR 236) in Early Draft Review!

A concurrency API for Java EE has been long awaited by the community. In fact, JSR 236 -- Concurrency Utilities for Java EE was started in 2003. The great news is that JSR 236 has been making serious headway just in time for Java EE 7! JSR 236 released it's Early Draft Review just a few days ago. You can read it and provide your feedback here as well as get involved.

Wednesday Apr 11, 2012

Concurrency Utilities for Java EE 6: JSR 236 Rebooting

JSR 166 added support for concurrency utilities in the Java platform. The JSR 236's, a.k.a Concurrency Utilities for Java EE, goal was to extend that support to the Java EE platform by adding asynchronous abilities to different application components. The EG was however stagnant since Dec 2003.

Its coming back to life with the co-spec lead Anthony Lai's message to the JSR 236 EG (archived here).

Concurrent Lanes

The JSR will be operating under JCP 2.8's transparency rules and can be tracked at concurrency-spec.java.net. All the mailing lists are archived here. The final release is expected in Q1 2013 and the APIs will live in the javax.enterprise.concurrent package.

Please submit your nomination if you would like to join this EG.

Wednesday Dec 07, 2011

Lesser-advertised Java EE.next JSRs

As you may have already read here, Java EE 7 (JSR 342) is well on its way with some JSRs having reached the early draft status (e.g. JAX-RS 2.0, JSF 2.2, CDI 1.1, ...).

ALT_DESCR

On the other hand, you may not have heard of the following JSRs that are all candidates for inclusion in the Java EE Platform:
State Management (JSR 350) was recently filed by Oracle to offer a standard API for a state management subsystem (examples of state include HTTPSession and any state associated with CDI scoping annotations).
Batch (JSR 352) was covered here just recently as it has recently passed the Review Ballot.
Concurrency Utilities for Java EE (JSR 236) is building on JSR-166 (java.util.concurrency) to provide a clean abstraction for threaded code in a managed environment. It has been ongoing for several years and should be revived and completed in time for Java EE 7.
Java API for JSON Processing (JSR 353) is a parsing API for manipulating (reading or writing) JSON content. Binding (JAXB-style) is not in the scope of this newly submitted JSR.

The exact list of JSRs that will be part of Java EE 7 is up to the expert group to decide. Arun has more details on the status of each JSR.