Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between MDB and JMS

Please let me know what is the difference between:

  • Message Driven Beans (MDB)
  • Java Message Service (JMS)
like image 821
JavaUser Avatar asked Jan 15 '11 13:01

JavaUser


2 Answers

JMS and Message-driven beans are not either/or choice, the two are complimentary.

JMS is the API and technology for passing messages around. Message-driven beans (MDB) are an API for receiving JMS messages as events in the EJB style. There are many ways of handling JMS messages, MDB is just one of them.

From the JavaEE tutorial:

Message-driven beans can implement any messaging type. Most commonly, they implement the Java Message Service (JMS) technology.

Your subject, by the way, talks abut MBeans - this is entirely different (that refers to the JMX API), and nothing to do with JMS.

like image 162
skaffman Avatar answered Oct 21 '22 00:10

skaffman


JMS is the Java Messaging Service specification; it's the API for queues and topics in Java EE.

The MDBs that I'm familiar with typically implement the javax.jms.MessageListener interface, encapsulating the topic or queue listener into a component that's managed by the Java EE container.

But it's been pointed out to me in the comments that this is not a requirement; MDBs can be used as part of the Java Connector API.

like image 40
duffymo Avatar answered Oct 20 '22 22:10

duffymo