Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

How Your WCF Service Can Use MSMQ as a Durable Message Store

Adding MSMQ to your WCF-based service adds complexity, but any challenges from that complexity are greatly outweighed by the benefits.


advertisement
y previous DevX article "WCF and MSMQ—Take a Message" explained the benefits of introducing queues into an application architecture. Queues provide a useful isolation layer between a service and a caller (or vice-versa) and become a place for messages to live while waiting to be processed. To summarize that article, when queues are used properly they can:
  • Increase application robustness, because clients can send messages even when services are not running
  • Increase application scalability, as multiple service instances can be used to process messages from a single queue
  • Improve client responsiveness, thus eliminating the need for clients to wait on a response from the service
  • Reduce dependencies between client and services, because all communication is indirect via queues
  • Ensure the durability of messages, because they can survive service and system failures

Through the MsmqIntegrationBinding and NetMsmqBinding bindings, Windows Communication Foundation (WCF) has baked-in integration with Microsoft Message Queuing (MSMQ), which makes building applications simple. The following are the two solutions for which you can utilize the integration between WCF and MSMQ:

  1. A WCF client application can communicate with an existing MSMQ-based application using the MsmqIntegrationBinding binding. In essence, a WCF-based client can be used to place messages directly into an MSMQ queue. The client can then be processed by another application (referred to hereafter as a service for the sake of simplicity).
  2. A WCF service or client can use an MSMQ queue as a message store via NetMsmqBinding. The WCF endpoints are unchanged; the key differentiator being messages are placed into queues to await processing rather than being sent directly into the WCF runtime.

The first solution is basically legacy integration, while the second is a full-on WCF solution that happens to utilize MSMQ as a durable message store. This article walks through the steps necessary to facilitate the second solution.



Author's Note: When developing MSMQ-backed WCF services, do not use the ASP.NET Development Server built into Visual Studio. It lacks support for the necessary protocols. Instead, use IIS or create a custom host for your WCF service. The example in this article employs IIS as the host.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap