Over a million developers have joined DZone.

Asynchronous Servlets and Java EE Concurrency Utilities

· Java Zone

Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code! Brought to you in partnership with ZeroTurnaround.

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 demonstratedhere.

The Java Zone is brought to you in partnership with ZeroTurnaround. Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code!

Topics:

Published at DZone with permission of Reza Rahman, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}