Learn JMS vs AMQP, comparison between JMS and AMQP. Both Seem to be same with different protocols and specs. Where should we use JMS or AMQ and its Use cases?
1. Overview of JMS Vs AMQP
This blog post described about basic differences and similarities between JMS (Java Message Service) and AMQP (Advanced Message Queuing Protocol). JMS and AMQP both seems to be same with its different protocol and different implementation, used for the same purpose.
What is purpose here, purpose of implementation is to talk between two differen application in asyncronous fashion. JMS is a API while AMQP is a protocol (wired-level protocol).
2. 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. JMS is used for asynchrounous integration between two different Java applications.
3. 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 written in Java.
- JMS providers: OpenMQ (glassfish’s default), HornetQ(Jboss), and ActiveMQ etc.
- Supports 4 types of data type:
TextMessage, BytesMessage, ObjectMessage, StreamMessage, MapMessage
4. Key points of AMQP (Advanced Message Queuing Protocol)
You can find key points here about AMQP for understanding AMQP vs JMS.
- 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.
5. 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 | AMQ | |
---|---|---|
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' |
6. Where should we use JMS or AMQP?
I’m explainig one use case over here for different clients for sending and receiving the message over network.
Let’s take an example, our client application is in Java which wants to send a message to a Ruby-based client or vice-versa. In this use case JMS
queue mechanism will not work as two applications written in different languages. Client can’t talk to JMS
client, we need a message broker which can remove the gap between two client or platform. To solve the problem we look for something else, which might be STOMP this way, we provide solutions in a coupled manner, somewhere designing poorly way. but this might be not good for down the line maybe after 5 years.
Think, if the language of one of the clients 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 this scenario AMQP will be more suitable and in-fact handy. why? because AMQP is around a binary wire protocol that 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.
7. Conclusion of JMS Or AMQP
There is an endless debate on these two topics but it depends upon context. In software fields everything is contextual. You may hear that, “the best practices of today can be the worst practice of tomorrow ” there is no doubt in this. If the problem context gets change, your solution domain may change as well. For me, both of them are equally important but depends upon the 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 discussion, AMQP is all around defining the ‘what’, and JMS is about defining the ‘how’.
8. Reference
I hope you enjoyed this post about JMS vs AMQP comparative study, its use cases, where should we use JMS and where should we use AMQP. Differences between JMS and AMQP, and you can visit software architecture tutorial for more details.
- Oracle Java JMS for more details.
- AMQP for more details.
You reach this point, it means you like this blog post, please write you comment/suggestion to improve this post. cheer 🙂 happy learning 🙂 about JMS vs AMQP comparative study.