EJB 2.0 only supported JMS messages in Message-Driven Beans. If an enterprise system needed to receive non-JMS messages (like EbXML, legacy system messages), it couldn’t use MDBs. There was no standard way to plug in different message types.
From EJB 2.1+, MDBs can consume any message type (not just JMS) by using J2EE Connector Architecture 1.5 (JCA) resource adapters. These act as pluggable message providers that handle message inflow from any enterprise system.
- MDB implements a message listener interface specific to the message type (e.g.,
javax.jms.MessageListenerfor JMS, or customcom.xyz.messaging.EbXMLMessageListenerfor EbXML) - A Resource Adapter (based on JCA 1.5) is written for the specific message type
- The resource adapter uses JCA message inflow contracts to deliver messages to MDB endpoints
- Resource adapter is plugged into any J2EE-compliant application server (standard component)
- Container delegates message delivery to the resource adapter, which calls
onMessage()on the MDB
- JAX-RPC doesn’t support EbXML or asynchronous messaging
- Write a resource adapter with
EbXMLMessageListenerinterface - MDB implements this interface → can now receive EbXML messages
- Resource adapter handles the protocol; MDB just processes the message
- EJB 2.0: MDB only supported JMS messages
- EJB 2.1+: Any message type via JCA resource adapters
- Resource adapters are standard J2EE components — pluggable into any compliant server
- MDB uses different listener interfaces for different message types
- Decouples MDB from specific messaging protocols
- Built from: MDB — pluggable providers extend what MDB can consume
- Built from: MOM — JCA can integrate non-JMS MOM systems
- Related: JMS — JMS is one (default) type of message provider for MDBs
- Related: EJB Container — container manages MDB and resource adapter interaction
- Contrasts with: Session Bean — session beans don’t use message listeners
- EJB 2.0 MDBs cannot consume non-JMS messages (must upgrade to 2.1+)
- Writing custom resource adapters requires deep knowledge of JCA 1.5 specification
- JAX-RPC only supports SOAP 1.1 and is not asynchronous — JCA is the solution for async non-SOAP
- Each message type needs its own listener interface implemented by the MDB