Message queue

Official Content

Message sending and reception is a communication mechanism between processes and applications. A process/application may send messages to several clients as well as receive messages from several clients. These messages are sent to message queues. Message queues are containers that host messages while in transit. Thus, processes and applications get connected to message queues that have mechanisms to send and receive messages. The main purpose of the queue is to provide a route and guarantee that the messages will be delivered.

Therefore, message queues allow for communication between processes/applications that are not continuously connected. The natural communication process is as follows: a client sends a message to a queue and then the receiver will read the message from the same queue. Nevertheless, the most interesting aspect of this mechanism is that the one who sends the message and the one who receives it do not need to be running at the same time, thus introducing the concept of asynchronous communication.

In client/server environments, when application A wants to communicate with application B, application A needs to know where application B is located (e.g.: it needs to know its IP address). Also, it needs application B to be listening at this moment. When using a message system, application A sends a message; the message system receives the message and sends it to B, and B will receive the message once it gets connected to the service (the queue). This enables asynchronous communication between A and B; that is to say, B does not need to be present the moment the message is sent, and it will receive the message anyway, in spite of not being present. In fact, the one who sends the message does not need to know anything at all about the one that receives the message and vice versa. The only thing that must be known is the message structure to process it later on.