O'Reilly Book Excerpts: Enterprise JavaBeans, 3rd Edition
EJB Message-Driven Beans
This excerpt is Chapter 13 from Enterprise JavaBeans, 3rd Edition, published in September 2001 by O'Reilly.
This chapter is divided into two subsections: "JMS as a Resource" and "Message-Driven Beans." The first section describes the Java Message Service (JMS) and its role as a resource that is available to any enterprise bean (session, entity, or message-driven). Readers unfamiliar with JMS should read the first section before proceeding to the second section.
If you're already familiar with JMS, you can skip directly to the second section, which provides an overview of the new enterprise bean type -- the message-driven bean. A message-driven bean is an asynchronous bean activated by message delivery. In EJB 2.0, vendors are required to support JMS-based message-driven bean, that receive JMS messages from specific topics or queues and process those messages as they are delivered.
All EJB 2.0 vendors must, by default, support a JMS provider. Most EJB 2.0 vendors have a JMS provider built in, but some may also support other JMS providers. Regardless of how the EJB 2.0 vendor provides the JMS service, having one is a requirement if the vendor expects to support message-driven beans. The advantage of this forced adoption of JMS is that EJB developers can expect to have a working JMS provider on which messages can be both sent and received.
In this chapter:
The ReservationProcessorBean Class
The onMessage( ) method: Workflow and integration for B2B
Sending messages from a message-driven bean
XML deployment descriptor
Message selector examples
The ReservationProcessor clients