J2EE Programming/Message Driven Bean

From Wikibooks, open books for an open world
Jump to: navigation, search

Enterprise JavaBeans integrates the functionality of Message-Oriented Middleware (MOM) into its component model. This integration extends the EJB platform so that it supports both RMI and asynchronous messaging. EJB 2.0 and 2.1 support asynchronous messaging through the Java Message Service (JMS) and a component called the Message-Driven Bean. It can receive and send asynchronous JMS messages, and can easily interact with other EJBs. In addition to JMS, message-driven beans in EJB 2.1 can support other synchronous and asynchronous messaging systems.

EJB 2.1 extends the programming model of the message-driven bean beyond JMS to any messaging system. While vendors must continue to support JMS-based message-driven beans (JMS-MDBs), other types of messaging systems are also allowed. It’s likely that vendors will develop new message-driven bean types to support all kinds of protocols, including SMTP for email, SNMP for device control, peer-to-peer protocols (e.g., BEEP and Jabber) and many other open and proprietary messaging systems. In addition, the message-driven bean has become an elegant option for serving connections to legacy transaction processing systems like CICS, IMS, openUTM, and others.

The expansion of message-driven beans in EJB 2.1 to other protocols is made possible by the new J2EE Connector Architecture (JCA 1.5), which defines a portable programming model for interfacing with enterprise information systems. The use of JCA in J2EE is analogous to the use of USB in computer hardware. A computer that supports USB can interface with just about any USB-compliant device. Similarly, an EJB 2.1 container that supports JCA 1.5 can interface with any JCA 1.5-complaint resource. For example, if a XYZ Vendor creates a new message-driven bean component for their proprietary messaging system based on JCA 1.5, that component will be portable across all EJB 2.1-compliant servers.

Figure 1-1 EJB 2.1 Message-driven beans and JCA 1.5[edit]

Message-driven beans in EJB 2.1 and 2.0 allow other applications to send messages that can be captured and processed by the EJB application. This feature allows EJB applications to better integrate with legacy and other proprietary systems.

Clipboard

To do:
Add code and examples.