This 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. what is 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
- Java Message Service is an API that is part of JEE (Java enterprise edtion) for sending messages between two or more clients.
- JMS providers: OpenMQ (glassfish’s default), HornetQ(Jboss), and ActiveMQ etc.
- Supports 4 types of data type:
TextMessage, BytesMessage, ObjectMessage, StreamMessage, MapMessage
2. AMQP (Advanced Message Queuing Protocol)
Key points about AMQP:
- AMQP is protocol between a messaging client and messaging server.
- It support four models: direct, fanout, topic and headers.
- It supports 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 specs. Let us discuss few of them are as follows:
|JMS is a standard API||AMQP is a protocol|
|Messaging Model||JMS supports two models: one to one and publish/subscriber.||AMQP supports 4 models: direct \, fanout \, topic\, headers|
|Data types||JMS supports 5 different data types:||AMQP RabbitMQ supports only the binary data type.|
|Workflow strategy||in JMS producers send to the queue or topic directly||In AMQP producers send to the exchange then the queue.|
|Technology compatibility||JMS is specific for java users only||AMQP supports many technologies e.g. RabbitMQ|
|Language||JMS is specific for java users only||but AMQP supports many technologies|
|JMS is about defining the 'how'||AMQP is around of defining the 'what'
4. 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 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? The answer will be NO, it won’t.
For overcoming of 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 you are using for sending to or receiving from 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’.
You reach to this point , it means you like this article, please write you comment/suggestion to improve this post. cheer 🙂 happy learning 🙂