Difference between MDB and JMS

11,884

Solution 1

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.

Solution 2

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.

Share:
11,884
JavaUser
Author by

JavaUser

Updated on July 31, 2022

Comments

  • JavaUser
    JavaUser almost 2 years

    Please let me know what is the difference between:

  • duffymo
    duffymo over 13 years
    +1 - good point about MBeans; it made for dissonance between the question and text.
  • skaffman
    skaffman over 13 years
    @JavaUser: Not "built on top of", no, there is no coupling between the two APIs. It is the most common usage of MDBs, though - they generally implement the MessageListener interface.
  • Arjan Tijms
    Arjan Tijms over 13 years
    ''MDBs are built on top of the JMS API.'' - Sorry, but that's not correct. JMS is a common provider of (async) messaging for MDBs, but MDBs can act as an endpoint (listener) for any service which provides a JCA resource adapter. At no point are MDBs build on top of any part of the JMS API.
  • duffymo
    duffymo over 13 years
    I've only used them with JMS; I wasn't aware of the JCA connection. And "on top of" in my mind meant "using the MessageListener interface", which is a JMS package. Your answer is certainly more complete, but "at no point" seems to go too far for me. I'd love to see a production citation of someone who used MDBs for something other than JMS.
  • Akabelle
    Akabelle almost 9 years
    @skaffman I see that the original question was edited, so your last sentence lost its sense - yet this was the thing that brought me here; your remark and an other post (theserverside.com/news/thread.tss?thread_id=31199) helped answering my question. Thanks!