EJB Message-Driven Beans
|
Related Reading
Enterprise JavaBeans |
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:
Reimplementing the TravelAgent EJB with JMS
TopicConnectionFactory and Topic
TopicConnection and TopicSession
TopicPublisher
Message types
JMS application client
JMS Messaging Models: Publish-and-Subscribe and Point-to-Point
Publish-and-subscribe
Point-to-point
Which messaging model should you use?
Entity and Session Beans Should Not Receive Messages
The ReservationProcessorBean Class
MessageDrivenBean interface
MessageDrivenContext
MessageListener interface
The onMessage( ) method: Workflow and integration for B2B
Sending messages from a message-driven bean
XML deployment descriptor
<message-selector>
Message selector examples
<acknowledge-mode>
<message-driven-destination>
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