Questions on REST with MSMQ

Question:

I am looking for a solution for this situation - we have server, which hosts ASP.NET application with WCF REST API. We also have applications that post data to REST service. However, sometimes these applications are not online but data still needs to be transferred.
How could we use MSMQ binding when applications are offline? How to switch to MSMQ bindings when application is offline?
Both server and client applications use Windows Server 2003, IIS 6.0, .NET 3.5

Answers:

For your scenario, you want to use REST model for the main communication between client asp.net app and backend WCF service, but also use MSMQ when the service application is not available(for persist the requests), correct?
I think you can consider the following approaches:
1) The first idea is exposing two services(different endpoint) on the server. One is the original REST service which may not be available. And another service is using WCF msmq binding which(and turn on reliable and durable message features to ensure message reliabitliy). Thus, your client-side will need to determine the service availablility, if the REST service not available, turn to the MSMQ binding WCF service.  For using msmq binding in WCF, here are some resources.
#Queuing in WCF
http://msdn.microsoft.com/en-us/library/ms789048.aspx

#How Your WCF Service Can Use MSMQ as a Durable Message Store
http://www.devx.com/dotnet/Article/41482

#Sample Starter Project Using WCF and MSMQ
http://www.codeproject.com/KB/WCF/WCF_MSMQ_Integration.aspx
2) The second approach is directly using raw MSMQ programming(via System.Messaging namespace API), which send raw MSMQ message(when your wcf REST service not available), and your WCF service may also need to have a background task thread to monitor the MSMQ queue(which may contains message received during the offline time of the REST service).
For raw MSMQ programming in .NET, here are some useful articles:
#Programming MSMQ in .NET - Part 1
http://www.codeproject.com/KB/dotnet/mgrmsmq.aspx

#Leveraging MSMQ in ASP.NET Applications
http://www.15seconds.com/issue/031202.htm


Please remember to mark the replies as answers if they help and unmark them if they provide no help. Posted in: problems and solutions | Tags: questions answers q&a questions and answers msmq rest wcf reliability wcf service binding library message queue