Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Asynchronous Servlets and Java EE Concurrency Utilities

DZone's Guide to

Asynchronous Servlets and Java EE Concurrency Utilities

· Java Zone
Free Resource

Learn how to troubleshoot and diagnose some of the most common performance issues in Java today. Brought to you in partnership with AppDynamics.

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.

Understand the needs and benefits around implementing the right monitoring solution for a growing containerized market. Brought to you in partnership with AppDynamics.

Topics:

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

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}