JMS Versus AMQP

Java EEThis article described about basic differences between JMS (Java Message Service) and AMQP (Advanced Message Queuing Protocol). JMS and AMQP both seems to be basically used for the same purpose. JMS is a API while AMQP is a protocol (wired-level protocol)

1. JMS (Java Message Service)

Java Message Service is an API that is part of Java EE for sending messages between two or more clients. There are many JMS providers such as OpenMQ (glassfish’s default), HornetQ(Jboss), and ActiveMQ.

Key Points of JMS

  1. Java Message Service is an API that is part of JEE (Java enterprise edtion) for sending messages between two or more clients.
  2. JMS providers: OpenMQ (glassfish’s default), HornetQ(Jboss), and ActiveMQ etc.
  3. Supports 4 types of data type: byte, Map,

2. AMQP (Advanced Message Queuing Protocol)

Key points about AMQP:

  • AMQP is protocal between a messaging client and messaging server.
  • It support four models: direct, fanout, topic and headers.
  • It suports only binary data type.
  • This is emerging technology nowadays;
  • A number of implementation different message broker on AMQP : RabbitMQ (open source message broker which uses AMQP standard).
  • AMQP is language independent, e.g. RabbitMQ written in Erlang language
  • AMQP can queue and rout messages. It can go P-2-P (One-2-One), publish/subscribe, and some more, in a manner of reliability and secured way.
  • AMQP provides a description on how a message should be constructed. It doesn’t provide an API on how the message should be sent.

3. Difference between JMS and AMQP

Both JMS and AMQL seems similar in nature but with different standard and different spec. let us discuss few of them are as follows:

No. JMS AMQP
1 JMS is a standard API AMQP is a protocol
2Messaging Model JMS supports two models: one to one and publish/subscriber. AMQP supports 4 models: direct , fanout , topic, headers.
3 Data types JMS supports 5 different data types: AMQP RabbitMQ supports only the binary data type.
4 Workflow strategy in JMS producers send to the queue or topic directly In AMQP producers send to the exchange then the queue.
5Technology compatibility JMS is specific for java users only AMQP supports many technologies e.g. RabbitMQ.
6Language JMS is specific for java users only but AMQP supports many technologies.
7 JMS is about defining the 'how' AMQP is around of defining the 'what'

Where should we use JMS or AMQP?

Here I’m taking one use case over here for different clients for sending and receiving the message over network.

Let’s take an example over here, our client application is in Java which want to send a message to Ruby based client or vice-versa. In this case JMS client can’t talk to JMS client, we need a message broker which can remove the gap between two client or platform. To solve problem we look for something else , which might be STOMP this way, we are provides solutioning in coupled manner, somewhere designing poorly way. but this might be not good for down the line may be after 5 years.

Think, if language of one of the client gets changed? It means , if Java client changed to C# client and another end will be Ruby client. Will this work? NO, it won’t.

For this scenario AMQP will be more suitable and in-fact handy. why ? because, AMQP is around a binary wire protocol which was designed for interoperability between different vendors and platforms. AMQP provides a standard messaging protocol that stands across all platforms, no matter which AMQP client your using for sending or receiving of messages.

5. Conclusion of JMS Or AMQP

This is endless debate on these two topics but it depends upon context. In software fields everything contextual. You may heard that , “the best practices of today can be the worst practice of tomorrow ” there is not doubt in this. If problem context gets change , your solution domain may change as well. For me, both of them are equally important but depends upon context, where we tried to fit what? what we are looking for? how we use in what context and all..

To wrap this up and end this short discussing, AMQP is all around of defining the ‘what’, and JMS is about defining the ‘how’.

if you like this , please write you comment/suggestion to improve this post. cheer 🙂 happy learning 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *