Take the 2-minute tour ×

I am trying to understand the basics of Message Queues. I see that there are many implementations available as libraries for MQs (ActiveMQ, RabbitMQ, ZeroMQ etc). Also J2EE enabled servers provide such support I think.
What I fail to understand about the topic, is how are these kind of constructs used by real software. I mean what kind of messages are usually being exchanged? Strings? Binary data?
If I understand correctly one can configure the transport protocol, but what is usually the application data format?
Is it a new way of communication, like e.g. SOAP WS or REST WS or RPC etc where each has a different application msg format?

share|improve this question
add comment

2 Answers

Message queues usually using for application integration. In enterprise it is usually used to implement ESB, but nowadays there are smaller application systems that utilize similar patterns.

Concerning data being transmitted - usually it is XML messages, but actually depends on applications and MQ software - some of them are able to handle binary messages, some are not.

For example imagine you have two applications which require data interchange. If you integrate them using some kind of messaging software such as ActiveMQ, for example, then it will give you some benefits like routing, fault-tolerance, balancing, etc, out-of-the-box. You may integrate your applications using MQ directly, but ESBs usually give you ability to use web services: app just calls ws of ESB and knows nothing about underlying architecture. Also MQs and ESBs gives you a level of abstraction: you may switch your apps in a system absolutely transparent, as long as data exchange interface is preserved.

share|improve this answer
So the messages are XML but instead of using SOAP or REST directly you use these systems so as not to have to implement fault-tolerance, balancing etc as you mentioned in your SOAP or REST server? –  Jim Oct 26 '13 at 9:52
Yes if we a talking about MQ only, the I wolud say this is the main reason. But if using not only MQ, but a complete ESB, then this ESB may also perform some business-logic (usually in kind of messages transformations) itself. –  Andy Oct 26 '13 at 10:00
Actually this topic is wide enough, because there are many MQ software and they have different features. In general MQ let you integrate software easily, whatever it means :) For example IBM WebSphere MQ supports virtually any platform from mainframes to embedded systems, so it may be used just to integrate old mainframe to modern application stack. –  Andy Oct 26 '13 at 10:04
Imagine you have two applications: HR and Accounting. They needs to interchange data about employees who is absent because of being ill. You may integrate them point-to-point (using web services or whatever), but then you must think about fault tolerance yourself - what if one application is down? Then another application must collect data to send it later. This may be done by MQ automaticly and completely transparent. What if 3rd application will come into a system, with a need of same data? If using MQ it will be much easier - just reconfigure routing rules. –  Andy Oct 26 '13 at 10:15
add comment

MQs are mainly used for interprocess communication, or for inter-thread communication within the same process. They provide an asynchronous communications protocol, meaning that the sender and receiver of the message do not need to interact with the message queue at the same time. Messages placed onto the queue are stored until the recipient retrieves them.

wikipedia can be good intro to topic. http://en.wikipedia.org/wiki/Message_queue#Standards_and_protocols

Also, to understand diff between webservice and mq, read this thread: Message Queue vs. Web Services?

share|improve this answer
But how does the queue know which msg is for which recipient? –  Jim Oct 26 '13 at 10:33
en.wikipedia.org/wiki/Message_queue#Usage .. A message listener registers with the queue and is notified when message arrives in queue. Routing policies can be used for complex situations. –  drop.in.ocean Oct 26 '13 at 10:43
I read the link.It is too vague.Is the idea that the registered listeners get notified for messages of specific type?I thought that the message placed on a queue is addressed somehow to a specific recipient (e.g. IP?) –  Jim Oct 26 '13 at 10:57
MQs are meant for inter process communication within usually a machine or set of machines under an organisation. eg a typical example is an app might notify MQ with message on financial transaction that occurred. Theses messages are later, asynchronously, processed by reporting app to generate reports. –  drop.in.ocean Oct 26 '13 at 11:11
So the messages does not address a specific recipient?It is about a topic? I think this is what you describe in your example, right? –  Jim Oct 26 '13 at 12:17
show 1 more comment

Your Answer


