Microsoft Message Queue (MSMQ)
MSMQ provides solutions to a range of problem scenarios that appear during application development.A common example is in client-server architecture where a direct connection to the server is needed to handle information updates. In this situation, any disruption to the server will cause all client applications to fail, possibly causing idle staff and lost productivity. Such a disruption may be caused by a hardware failure, power outage, or a server upgrade.The solution is to use message queuing to "uncouple" the client and the server by providing a storage point for communication between them. Now, if a connection to the server cannot be made, data entered in client application can be stored in a client-side message queue. Once a connection is reestablished, the messages are then automatically forwarded to the destination queue on a remote server.An application on the server will then read the messages from the message queue and perform the necessary database updates.
A similar situation to the client/server scenario is when it becomes quite common for client applications to be disconnected from the network. Sales staff often use notebook computers to run their sales applications while they are on the road. Some may type in information directly into the notebook, whereas others may wait until they arrive back at the office. Instead of writing code to handle the online and offline situations (and possibly an "upload to server" function), using message queuing to handle both cases is more efficient. In online mode, all messages will be sent directly to the server queue. In offline mode, the messages will be temporarily stored on the client, ready for forwarding to the server queue when the network connection is made.
MSMQ also provides the plumbing you need for true distributed processing. A good example of this is in the area of mathematical computation. If the work required to find a solution to a mathematical problem can be divided into pieces then such pieces could be placed on a queue. Each piece would constitute a message containing all the information required for an idle computer on a network to get started on the problem.These computers could take a piece of the mathematical puzzle, calculate their share of the solution, and send the result back to the queue.A central controlling application could then correlate the response messages with the request messages and combine these results into the total solution. You may also need MSMQ when you hear the following during conversations between IT personnel:
"Not again!,This Web server always takes at least three minutes to respond on Monday morning, and my app slows to a crawl."
"The application locks up when they back up the server every night. What can we do?"
"How can we trace the communication between these applications?"
"Last time our server was offline, we had 50 data entry operators idle for an hour. How can we avoid this in the future?"
A side effect of using MSMQ in your applications is that you can now easily trace the messages sent between your application tiers.This tracing can help with auditing and debugging your application.You can also authorize new applications to hook onto your messaging infrastructure to reuse the services that your message queuing applications provide.