The basic principles of MSMQ are remarkable simple. When you want to pass a message on to another application, you just create it, wrap it up in a special package, and dump it into a message queue. The receiving application can interrogate the message queue and retrieve any waiting messages whenever it likes. Until it does, the message sits in the queue waiting.
Connectionless Messaging
This is, of course, how email works. A user sends their email message to their own mail server, where it is stored and then forwarded to the appropriate mail server for the recipient to collect. Of course, the sender and recipient may be using the same mail server, so the message is simply stored in the recipient's mailbox there. If they aren't connected to their mail server when the message arrives (perhaps they use a dial-up account rather than a permanent connection) it waits in their mailbox until they do connect and retrieve their mail. This is store-and-forward messaging, and it provides the kind of connectionless messaging environment we need in our distributed applications.
Guaranteed Once-Only Delivery
Email servers also provide extra features to make the delivery of email more reliable, and MSMQ implements the same kind of core features. For example, a message is only flagged as received by the recipient once they signal to the mail server that the message arrived intact. Until then it is marked as undelivered, so a network failure while it is being delivered will leave it as 'new mail' on the mail server ready to be collected again. Once it's been safely delivered and acknowledged, it is marked as such. The mail server will only send it as new mail once, and will keep trying to deliver it until it is successful (or generate a return message to indicate an error if it can’t be delivered after a preset time).
Prioritization and Routing
On most systems, email messages can optionally be marked as 'urgent', and these will be delivered first by the mail server—either directly to the recipient, or to the recipient's mail server. It's also possible to configure the mail server to route messages depending on rules. And of course, out on the Internet, dynamic routing is the norm anyway. Packets can take different routes to their destination depending on network traffic and availability. MSMQ can provide all these kinds of features as well.
Message and System Security
Users have to identify themselves to the mail server before both sending and receiving messages. They can also encrypt and digitally sign messages to prevent unauthorized interception and tampering with the content. Again, MSMQ provides these kinds of features to the messages and data it transmits between applications.
Disparate System Integration
Finally, email is often a platform-independent communication method. Users can send text email and attached files to recipients that use different email software, and which can run on different platforms and in different environments. MSMQ message data is stored in a format that both sender and recipient agree on, and so it doesn't matter what the recipient's environment looks like—it can convert the data into whatever format it likes after receipt.
Supported Platforms
MSMQ only directly supports Windows NT (Server and Workstation) and Windows 9x. However, because the data format is standardized, other platforms can use it to communicate with Windows applications, and with each other. A company called Level 8 Systems manufactures a range of components that can access proprietary message queues on other systems, such as IBM MVS, MQ, CICS, OS/2, and AS/400 platforms; Sun Solaris, HP-UNIX, and AIX UNIX.
The SDK supplied with MSMQ also allows you to build applications and components that can integrate with MSMQ in other environments.
For more information on the Level 8 Systems products see their web page at
. Microsoft also provide their own MSMQ pages at http://www.level8.com/
.http://www.microsoft.com/msmq/