JMS and AMQP - RabbitMQ

62,308

Solution 1

Your question is a bit messy but Let's see its bits one by one.

General concept:

The Java Message Service (JMS) API is a Java Message Oriented Middleware (MOM) API for sending messages between two or more clients. JMS is a part of the Java Platform, Enterprise Edition, and is defined by a specification developed under the Java Community Process as JSR 914. It is a messaging standard that allows application components based on the Java Enterprise Edition (Java EE) to create, send, receive, and read messages. It allows the communication between different components of a distributed application to be loosely coupled, reliable, and asynchronous.

Now (from Wikipedia):

The Advanced Message Queuing Protocol (AMQP) is an open standard application layer protocol for message-oriented middleware. The defining features of AMQP are message orientation, queuing, routing (including point-to-point and publish-and-subscribe), reliability and security.

And the most important thing (again from Wikipedia):

Unlike JMS, which merely defines an API, AMQP is a wire-level protocol. A wire-level protocol is a description of the format of the data that is sent across the network as a stream of octets. Consequently any tool that can create and interpret messages that conform to this data format can interoperate with any other compliant tool irrespective of implementation language

Some important things you should know:

  1. Keep in mind that AMQP is a messaging technology that do not implement the JMS API.
  2. JMS is API and AMQP is a protocol.So it doesn't make sense to say that what is default protocol of JMS, of course client applications use HTTP/S as the connection protocol when invoking a WebLogic Web Service.
  3. JMS is only a API spec. It doesn't use any protocol. A JMS provider (like ActiveMQ) could be using any underlying protocol to realize the JMS API. For ex: Apache ActiveMQ can use any of the following protocols: AMQP, MQTT, OpenWire, REST(HTTP), RSS and Atom, Stomp, WSIF, WS Notification, XMPP. I suggest you read Using JMS Transport as the Connection Protocol.

Good Luck :)

Solution 2

Let's start from the basis.

RabbitMQ is a MOM (Message Oriented Middleware), developed with Erlang (a TLC-oriented programming language) and implementing the wire protocol AMQP (Advance Message Queuing Protocol). Currently, many Client APIs (e.g., Java, C++, RESTful, etc.) are available to enable the usage of RabbitMQ messaging services.

JMS (Java Messaging Service) is a JCP standard defining a set of structured APIs to be implemented by a MOM. An example of MOM that implements (i.e. is compatible with) the JMS APIs is ActiveMQ; there's also HornetMQ, and others. Such middlewares get the JMS APIs and implement the exchange patterns accordingly.

According to above, taken the skeleton of JMS APIs, an instance of RabbitMQ and its Java Client APIs, it is possible to develop a JMS implementation making use of RabbitMQ: the only thing that one has to do, at that point, is implementing the exchange pattern (over RabbitMQ) according to the JMS specification.

The key is: a set of APIs, like JMS, can be implemented no matter of the technology (in this case, RabbitMQ).

Solution 3

JMS, when it was defined did not define a protocol between the JMS client and a messaging server. The JMS client, which implement the JMS API can use whatever protocol to communicate with messaging server. The client just need to be compliant with JMS api. Thats all. Ususally JMS clients use a custom protocol that their messaging server understands.

AMQP on other hand is a protocol between a messaging client and messaging server. A JMS client can use AMQP as the protocol to communicate with the messaging server. And there are clients like that available.

http://www.lshift.net/blog/2009/03/16/openamqs-jms-client-with-rabbitmq-server

Solution 4

  • Where does JMS API come into play here? JMS API should use AMQP client libraries to connect to RabbitMQ?

JMS is an API, so some JMS API's are implemented over the AMQP protocol (like Apache QPID JMS) while most JMS APIs use other protocols. If the version of the AMQP protocol is the same, such a client should be able to communicate with another AMQP client.

  • Usually we use JMS to connect Message brokers like RabbitMQ, ActiveMQ, etc. Then what is the default protocol used here instead of AMQP?

It depends on your configuration of that JMS API. For ActiveMQ, it could be AMQP but by default it is 'openwire'

Solution 5

What is JMS?

JMS is a Java standard that defines a common API for working with message brokers.

Why do we need JMS?

  1. It was introduced in 2001 and was adopted approach for a very long time for asynchronous messaging.

  2. Before JMS, what used to happen was each message broker had a proprietary API, making an application’s messaging code less portable between brokers.

  3. With JMS, all compliant implementations can be worked with via a common interface. So, if you are changing your broker say "Apache Active MQ" to "Apache ActiveMQ Artemis" you don't have to worry about the portability issues as the JMS interface ensures your code portability.

Cons of JMS?

  1. JMS in 2001, when it was defined didn't enforce any protocol between the JMS client and the JMS messaging server. JMS client could have used any protocol for communication and the client needed to make sure a protocol that was compliant with the JMS API.
  2. JMS is limited to Java applications.

What is AMQP?

  1. AMQP (Advanced Message Queuing Protocol) is kind of an open standard application layer protocol for delivering messages.
  2. AMQP 0.9.1 was published in November 2008.
  3. AMQP provides a description of how a message should be constructed. Unlike JMS, it doesn't provide an API on how the message should be sent.

Why AMQP?

  1. AMQP is just a protocol between a messaging client and the messaging server. So even a JMS client can use AMQP as the protocol to communicate with the messaging server.

  2. AMQP is a messaging protocol that stands across all platforms. It doesn't matter which AMQP client is used, as long as it's an AMQP complaint, it will hold.

Share:
62,308

Related videos on Youtube

Kevin Rave
Author by

Kevin Rave

Updated on July 08, 2022

Comments

  • Kevin Rave
    Kevin Rave almost 2 years

    I am trying to understand what JMS and how it is connected to AMQP terminology. I know JMS is an API and AMQP is a protocol.

    Here are my assumptions (and questions as well)

    • RabbitMQ uses AMQP protocol (rather implements AMQP protocol)
    • Java clients need to use AMQP protocol client libraries to connect / use RabbitMQ
    • Where does JMS API come into play here? JMS API should use AMQP client libraries to connect to RabbitMQ?
    • Usually we use JMS to connect Message brokers like RabbitMQ, ActiveMQ, etc. Then what is the default protocol used here instead of AMQP?

    Some of the above may be dumb. :-) But trying to wrap my head around it.

    • 2020
      2020 about 11 years
      @KevinRave: The selected answer is wrong on some main points it makes. I have added a comment so that you can look at it.
    • Freak
      Freak almost 11 years
      @KevinRave I have edited the answer.Now The controversial portion has replaced.Now the whole answer is perfectly OK
    • Freak
      Freak almost 11 years
      I dont know who edited my answer and gave this improper point which was at num 3.. because I already have asked the thing which kevin is saying at point 2.Always read carefully before down voting or making suggestions
    • java_geek
      java_geek over 9 years
      Have a look at the JMS section in this article. It has a very detailed explanation saipraveenblog.wordpress.com/2014/12/08/…
    • SyntaX
      SyntaX about 4 years
  • 2020
    2020 about 11 years
    I am not sure but I believe that AMQP also uses HTTP/S protocol but AMQP is enhacement is messaging protocol over HTTP : No. That is not correct. JMS uses simple HTTP but for RabbitMQ/ActiveMq, they uses enhanced protocol. : No. That is not correct. JMS is only a API spec. It doesnt use any protocol. A JMS provider (like ActiveMQ) could be using any underlying protocol to realize the JMS API. For ex: Apache ActiveMQ can use any of the following protocols: AMQP, MQTT, OpenWire, REST(HTTP), RSS and Atom, Stomp, WSIF, WS Notification, XMPP.
  • Freak
    Freak almost 11 years
    I have edited the answer.Now The controversial portion has replaced.
  • Freak
    Freak almost 11 years
    @brainOverflow I dont know who edited my answer and gave this improper point which was at num 3.. because I have asked the thing which you are saying at point 2.Always read carefully before down voting or making suggestions
  • Kevin Rave
    Kevin Rave about 10 years
    Nope. Its not the one I was looking at. But similar.
  • Freak
    Freak about 9 years
    i already added stuff from that PDF so you can go to some other links too
  • mvmn
    mvmn over 7 years
    What does TLC stand for?
  • Paolo Maresca
    Paolo Maresca over 7 years
    @mvmm TLC stands for Telecommunication. Please, have a look to [1]. [1] allacronyms.com/TLC/Telecommunication
  • niken
    niken over 3 years
    AMQP is not a wire-level protocol. Wikipedia is wrong , omg, who would have thunk it