I have create a WCF service and am utilising netMsmqBinding binding.
This is a simple service that passes a Dto to my service method and does not expect a response. The message is placed in an MSMQ, and once picked up inserted into a database.
What is the best method to make sure no data is being lost.
I have tried the 2 following methods:
Throw an exception
This places the message in a dead letter queue for manual perusal. I can process this when my strvice starts
set the receiveRetryCount="3" on the binding
After 3 tries - which happen instantanously, this seems to leave the message in queue, but fault my service. Restarting my service repeats this process.
Ideally I would like to do the follow:
Try process the message
Can I achieve this? If so how? Can you point me to any good articles on how best to utilize WCF and MSMQ for my given sceneria.
Any help would be much appreciated. Thanks!
Some additional information
I am using MSMQ 3.0 on Windows XP and Windows Server 2003. Unfortunately I can't use the built in poison message support targeted at MSMQ 4.0 and Vista/2008.
MSMQ is Microsoft Message Queuing developed by Microsoft and deployed in windows operating system. MSMQ Queue ensures that reliable messaging between a client and a Windows Communication Foundation (WCF) service. So first we need to enable this feature in our operating system.
Kafka, RabbitMQ, IBM MQ, Azure Service Bus, and ActiveMQ are the most popular alternatives and competitors to MSMQ.
Description. The Clear-MsmqQueue cmdlet clears queues. Specify queues to clear by using MessageQueue objects. This cmdlet returns a MessageQueue object that represents the cleared outgoing queue.
I think with MSMQ (avaiable only on Vista) you might be able to to do like this:
<bindings>
<netMsmqBinding>
<binding name="PosionMessageHandling"
receiveRetryCount="3"
retryCycleDelay="00:05:00"
maxRetryCycles="3"
receiveErrorHandling="Move" />
</netMsmqBinding>
</bindings>
WCF will immediately retry for ReceiveRetryCount times after the first call failure. After the batch has failed the message is moved to the retry queue. After a delay of RetryCycleDelay minute, the message moved from the retry queue to the endpoint queue and the batch is retried. This will be repeated MaxRetryCycle time. If all that fails the message is handled according to receiveErrorHandling which can be move (to poison queue), reject, drop or fault
By the way a good text about WCF and MSMQ is the chapther 9 of Progammig WCF book from Juval Lowy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With