|Oracle® Fusion Middleware Programming Message-Driven Beans for Oracle WebLogic Server
11g Release 1 (10.3.6)
Part Number E15493-05
|PDF · Mobi · ePub|
A message-driven bean (MDB) is an enterprise bean that allows Java EE applications to process messages asynchronously. An MDB acts as a JMS or JCA message listener, which is similar to an event listener except that it receives messages instead of events. The messages may be sent by any Java EE component—an application client, another enterprise bean, or a Web component—or by non-Java EE applications.
These are the key features of message-driven beans:
Clients do not access message-driven beans through interfaces. A message-driven bean has only a bean class.
A message-driven bean's instances retain no data or conversational state for a specific client. All instances of a message-driven bean are equivalent, allowing the EJB container to assign a message to any message-driven bean instance. The container can pool these instances to allow streams of messages to be processed concurrently.
When a message arrives, the container calls the message-driven bean's
onMessage method to process the message. The
onMessage method may call helper methods, or it may invoke a session or entity bean to process the information in the message or to store it in a database.
A message may be delivered to a message-driven bean within a transaction context, so that all operations within the
onMessage method are part of a single transaction. If message processing is rolled back, the message will be re-delivered.
For information about design alternatives for message-driven beans, see MDBs and Messaging Models.
For a description of the overall EJB development process, see Programming WebLogic Enterprise JavaBeans, Version 3.0 for Oracle WebLogic Server
MDBs can be configured to receive messages from JCA 1.5-compliant resource adapters, as defined by the JCA specification. To configure a MDB to use JCA, set the
resource-adapter-jndi-name deployment descriptor.
For more information, see the JCA 1.5 specification and "resource-adapter-jndi-name" in Programming WebLogic Enterprise JavaBeans for Oracle WebLogic Server.