Chapter 12. Message-Driven Beans

The Message-Driven Bean was introduced in EJB 2.0 to support the processing of asynchronous messages from a Java Message Service (JMS) provider. EJB 2.1 expanded the definition of the message-driven bean so that it can support any messaging system, not just JMS. This chapter examines both JMS-based message-driven beans, which all EJB 2.0 and EJB 2.1 vendors must support, as well as the expanded message-driven bean model available to EJB 2.1 developers.

JMS and Message-Driven Beans

All EJB 2.0 vendors must support a JMS provider. Most vendors have a JMS provider built in, but some may also support other JMS providers. EJB 2.1 vendors can support any JMS provider that complies with the J2EE Connector Architecture 1.5. However, regardless of whether your vendor has its own JMS provider, or allows you to integrate some other provider, a JMS provider is an absolute necessity for supporting message-driven beans. By forcing the adoption of JMS, Sun has guaranteed that EJB developers can expect to have a working JMS provider on which messages can be both sent and received.

JMS as a Resource

JMS is a vendor-neutral API that can be used to access enterprise messaging systems. Enterprise messaging systems (a.k.a. message-oriented middleware) facilitate the exchange of messages between software applications over a network. The role of JMS isn’t unlike the role of JDBC: just as JDBC provides a common API for accessing many different relational databases, JMS ...

Get Enterprise JavaBeans, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.