Google News
logo
EJB - Interview Questions
What is mdb in java?
A Message-Driven Bean (MDB) is a Java Messaging Service (JMS) message listener that can reliably consume messages from a queue or a subscription of a topic. The advantage of using an MDB instead of a JMS message listener is that you can use the asynchronous nature of a JMS listener with the benefit of the EJB container performing the following :
 
* The consumer is created for the listener. That is, the appropriate QueueReceiver or TopicSubscriber is created by the container.
* The MDB is registered with the consumer. The container registers the MDB with the QueueReceiver or TopicSubscriber and its factory at deployment time.
* The message acknowledgment mode is specified.

An MDB is an easy method for creating a JMS message listener.
 
MDB Overview : 
 
An MDB is a unique EJB whose function is to read or write JMS messages from a JMS Destination (topic or queue).
 
The OC4J MDB interacts with Oracle JMS, which must be installed and configured appropriately. Oracle JMS is installed and configured on an Oracle database. Within this database, the appropriate queue or table is created.
 
* The MDB opens a JMS connection to the database using a data source with a username and password. The data source represents the Oracle JMS resource provider and uses a JDBC driver to facilitate the JMS connection.
* The MDB opens a JMS session over the JMS connection.
* Any message for the MDB is routed to the onMessage method of the MDB from the queue or topic. Other clients may have access to the same queue or topic to put on messages for the MDB.
Advertisement