Alex Rivera | Logout

How do I handle message failure in MSMQ bindings for WCF

Asked 2008-09-17T11:15:21.357
17

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:

  1. Throw an exception

    This places the message in a dead letter queue for manual perusal. I can process this when my strvice starts

  2. 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

  • If this fails, wait 5 minutes for that message and try again.
  • If that process fails 3 times, move the message to a dead letter queue.
  • Restarting the service will push all messages from the dead letter queue back into the queue so that it can be processed.

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.

Edit
Report

1 Answer

1

Unfortunately I'm stuck on Windows XP and Windows Server 2003 so that isn't an option for me. - (I will re-clarify that in my question as I found this solution after posting and realised i couldn't use it)

I found that one solution was to setup a custom handler which would move my message onto another queue or poison queue and restart my service. This seemed crazy to me. Imagine my Sql Server was down how often the service would be restarted.

SO what I've ended up doing is allowing the Line to fault and leave messages on the queue. I also log a fatal message to my system logging service that this has happened. Once our issue is resolved, I restart the service and all the messages start getting processed again.

I realised re-processing this message or any other will all fail, so why the need to move this message and the others to another queue. I may as well stop my service, and start it again when all is operating as expected.

aogan, you had the perfect answer for MSMQ 4.0, but unfortunately not for me

answered 2008-09-17T12:43:24.017

Your Answer