Faking Poison Message Handling
MSMQ has gotten a bit of an upgrade in the latest releases, particular in the area of poison message handling. Let's look a bit though at what users of Windows Server 2003 can do in the meantime before the next version of Windows Server is officially available. The interesting control to look at for poison message handling is the set of actions that are available when a message is discovered to be poisonous. MSMQ 4 has four options for handling these messages:
- The Fault option causes an MsmqPosionMessageException to be thrown and the listening service stops processing messages. The offending message is left in the original queue.
The Drop option causes the offending message to be discarded.
- The Reject option causes a rejection notice to be sent back to the submitter. The offending message is removed from the queue.
- The Move option causes the offending message to be moved from the original queue to a separate poison queue.
If you don't want to lose messages and you don't want your service to shut down, then the most desirable option is to move the offending message to some other queue. Unfortunately, the Reject and Move options are not available for MSMQ 3. Your only choices are to fault the listening service or drop the message.
However, you can use the Fault option with WCF extensibility to fake more sophisticated poison message handling strategies at some cost to speed. The essence of the trick is to use the fault notification of the listening service to perform some corrective action. For example, here's the strategy that you would use to replicate the move option.
1.
Register an IErrorHandler to catch instances of MsmqPoisonMessageException as they occur.
2.
When a poison message is encountered, the service is shut down and your error handler is called.
3.
Use the message identifier in the exception to find the offending message in the original queue and move it to a separate queue that you've previously created.
4.
At the end of your error handler, restart the service if you were able to move the message.
The third step can be replaced with whatever action you'd like to customize your poison message handling behavior.
Next time: Measuring Reliable Session Speed
Comments
Anonymous
August 21, 2007
A few days ago I talked about how to enable tracing across service boundaries . The brief summary ofAnonymous
August 23, 2007
I could get used to this rolling out of bed into my office thing BizTalk Server The highly anticipatedAnonymous
December 02, 2008
I could get used to this rolling out of bed into my office thing BizTalk Server The highly anticipated R2 release (the one with WCF Adapters) of BizTalk Server 2006 is coming real soon! Worldwide launches take place in September and October . My very