What is the difference between JMS consumer and Message Driven Beans (MDB)

robin bajaj picture robin bajaj · Apr 13, 2011 · Viewed 9.1k times · Source

Is there any difference between an asynchronous JMS (Java Messaging Service) consumer vs an actual MDB (Message Driven Bean). The only difference I see is the MDB class has @MessageDriven annotation which the asynchronous JMS consumer doesn't.

Anything else that I am missing ?

Answer

anubhava picture anubhava · Apr 13, 2011

Your MDB works as JMS consumer in your case. MDB is EJB specific term and consumer is a JMS term. A JMS consumer can be a message driven POJO as well which is not technically an EJB.

Answers to comments

A1. Yes it is correct to say that a plain JMS consumer cannot be pooled/managed like an EJB unless that JMS consumer happens to be managed by containers like EJB or Spring containers.

A2. MDBs really just fulfills the requirement for asynchronous communication with EJBs. When they are JMS based then your MDB is technically a JMS Consumer as well. But an MDB can be non-JMS based as well eg: JCA (Java Connector Architecture) based MDB. You can see this post for more details about non-JMS based MDB: http://debupanda.blogspot.com/2006/08/using-ejb-30-message-driven-bean-with.html