MSMQ + WCF in a hosted environment
We have several systems that we're going to switch to use some typ开发者_如何学运维e of reliable architecture and using messaging is how we want to do it.
The thought is that we're going to use some cheap hosting (shared, not dedicated) to make calls but we need the calls to be reliable. If the destination server is not available, the message must be retried a few times before failing.
Web page is accessed > site adds a request to the queue > message is delivered to target end point
Is this do-able with shared hosting? What are other options if WCF + MSMQ wont work?
If you are able to use Server 2008 to for a WCF service with a netMsmqBinding endpoint to call the shared host then you can take advantage of the MSMQ 4 enhanced failed message handling features. With little extra coding, the WCF netMsmqBinding can be configure to automatically retry failed message and also remove a failed message from the queue to a special poison queue so the service can continue processing messages. You can manually move messages from the poison queue back to the main for re-processing once the share host is accessible again or write another service to handle this task automatically. This article on MSDN should is a good start for setting an MSMQ based WCF service and this article shows how the poison message handling works.
In a shared hosted environment it's up to the host if they will allow you to use MSMQ (or even rabbitQ which you wont be able to install yourself).
WCF over MSMQ works by WCF writing a message to a queue then MSMQ handles delivery of the message to the target and then it activates WCF with the message just as if you're calling it via SOAP.
Bottom line is: You will need to check if your host will allow message queues. If they do, make sure you add security to them so other sites on the server can't access them.
If MSMQ isn't installed on the server then you can't use net MsmqBinding
精彩评论