Message queue

From Wikipedia, the free encyclopedia

In computer science, a message queue is a software-engineering component used for interprocess communication. It utilises a queue for messaging -- the passing of control or of content.

[edit] Overview

Message queues provide an asynchronous communications protocol, meaning that the sender and receiver of the message do not need to connect to the message queue at the same time. Messages placed onto the queue are stored until the recipient retrieves them.

Most message queues have set limits on the size of data that can be transmitted in a single message. Those that do not have such limits are known as mailboxes.

Many implementations of message queues function internally: within an operating system or within an application. Such queues exist for the purposes of that system only.

Other implementations allow the passing of messages between different computer systems, potentially connecting multiple applications and multiple operating systems. These message queueing systems typically provide enhanced resilience functionality to ensure that messages do not get "lost" in the event of a system failure. Examples of commercial implementations of this kind of message queueing software (also known as Message Oriented Middleware) include IBM's WebSphere MQ (formerly MQ Series), Fiorano's MQ, Oracle Advanced Queuing (AQ) within an Oracle database, and Microsoft's MSMQ.

There are a number of open source alternatives for messaging middleware applications, such as Web Service Message Queue (WSMQ), JBoss Messaging, JORAM and ActiveMQ

[edit] Usage

In a typical message-queueing implementation, a system administrator installs and configures off-the-shelf message-queueing software (a queue manager), and defines a named message queue.

An application then registers a software routine that "listens" for messages placed onto the queue.

Second and subsequent applications may connect to the queue and transfer a message onto it.

The queue-manager software stores the messages until a receiving application connects and then calls the registered software routine. The receiving application then processes the message in an appropriate manner.

[edit] Synchronous vs. asynchronous

Many of the more widely-known communications protocols in use operate synchronously. The HTTP protocol -- used in the World Wide Web and in web services -- offers an obvious example.

In a synchronous model, one system makes a connection to another, sends a request and waits for a reply.

In many situations this makes perfect sense; for example, a user sends a request for a web page and then waits for a reply.

However, other scenarios exist in which such behaviour is not appropriate. For example, an application may need to notify another that an event has occurred, but does not need to wait for a response. Another example occurs in publish/subscribe systems, where an application "publishes" information for any number of clients to read. In both these examples it would not make sense for the sender of the information to have to wait if, for example, one of the recipients had crashed.

In such situations a system which does asynchronous message-queuing (or alternatively, a broadcast messaging system) comes to the fore.