Interview Questions

Which of the following are the benefits of MDB (Message Driven Beans) over standard JMS consumers?

BEA WebLogic Questions and Answers


(Continued from previous question...)

Which of the following are the benefits of MDB (Message Driven Beans) over standard JMS consumers?

Which of the following are the benefits of MDB (Message Driven Beans) over standard JMS consumers?
a. In case of a MDB, developer needs to create a MessageListener class that utilizes a server-wide session pool.
b. WebLogic Server container provides standard EJB services to MDBs.
c. MDBs benefit from the write-once, deploy-anywhere paradigm of EJBs.
d. MDBs can be associated with multiple Messaging Queues or Topics unlike standard JMS.


Choices B and C are correct. A message-driven bean is a special kind of EJB that acts as a message consumer in the WebLogic JMS messaging system. As with standard JMS message consumers, message-driven beans receive messages from a JMS Queue or Topic, and perform business logic based on the message contents. EJB deployers create listeners to a Queue or Topic at deployment time, and WebLogic Server automatically creates and removes message-driven bean instances as needed to process incoming messages.
Because message-driven beans are implemented as EJBs, they benefit from several key services that are not available to standard JMS consumers. Most importantly, message-driven bean instances are wholly managed by the WebLogic Server EJB container. Using a single message-driven bean class, WebLogic Server creates multiple EJB instances as necessary to process large volumes of messages concurrently. This stands in contrast to a standard JMS messaging system, where the developer must create a MessageListener class that utilizes a server-wide session pool. Thus choice A is incorrect.
WebLogic Server provides standard EJB services to MDBs, such as security services and automatic transaction management. Thus choice B is correct.
Being implemented as EJBs, MDBS benefit from the write-once, deploy-anywhere quality of EJBs. Whereas a JMS MessageListener is tied to specific session pools, Queues, or Topics, message-driven beans can be developed independently of available server resources. Thus Choice C is also correct.
Its not that MDBs are always advantageous as compared to standard JMS consumers. One limitation of MDBs compared to standard JMS listeners is that a given MDB deployment can be associated with only one Queue or Topic. If your application requires a single JMS consumer to service messages from multiple Queues or Topics, you must use a standard JMS consumer, or deploy multiple message-driven bean classes. Thus Choice D is incorrect.

(Continued on next question...)

Other Interview Questions