ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button O'Reilly Book Excerpts: Enterprise JavaBeans, 3rd Edition

EJB Message-Driven Beans

Related Reading

Enterprise JavaBeans
By Richard Monson-Haefel

by Richard Monson-Haefel

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:

JMS as a Resource

Reimplementing the TravelAgent EJB with JMS

TopicConnectionFactory and Topic
TopicConnection and TopicSession
Message types
JMS application client

JMS Is Asynchronous

JMS Messaging Models: Publish-and-Subscribe and Point-to-Point

Which messaging model should you use?

Entity and Session Beans Should Not Receive Messages

Learning More About JMS

Message-Driven Beans

The ReservationProcessor EJB

The ReservationProcessorBean Class
MessageDrivenBean interface
MessageListener interface
The onMessage( ) method: Workflow and integration for B2B
Sending messages from a message-driven bean
XML deployment descriptor
Message selector examples
The ReservationProcessor clients

The Life Cycle of a Message-Driven Bean

Does Not Exist
The Method-Ready Pool
Transitioning to the Method-Ready Pool
Life in the Method-Ready Pool
Transitioning out of the Method-Ready Pool: The death of an MDB instance

Pages: 1, 2, 3, 4, 5, 6, 7

Next Pagearrow