Welcome to MSDN Blogs Sign in | Join | Help

Handling Message Encoder Errors

This time it's two questions that have the same answer.

What contract does the message encoder have for producing a message from ReadMessage?

What should the transport do if the message encoder doesn't produce a message from the buffer you give it?

The contract of the message encoder is that it will always either throw an exception or produce exactly one message each time ReadMessage is called. This means that a properly-written message encoder will never fail to produce a message without throwing an exception out of ReadMessage for the transport to handle.

As you might recall, the contract that the transport must abide by is that operations should only throw exceptions that are subtypes of CommunicationException, TimeoutException, or some fatal exception type (such as OutOfMemoryException). The transport should catch all exception types that it knows the message encoder will produce, such as XmlException, and wrap those in some instance of CommunicationException. A good choice would be ProtocolException. However, the transport should not just eat all types of exceptions. It's best to let a stray exception through unless it is a specific, known type because you run the risk of trapping a fatal exception.

What happens to the message after the transport gets it back from the message encoder is no longer constrained by the contract of the message encoder.

Next time: How to Configure MaxItemsInObjectGraph

Published Monday, November 13, 2006 5:00 AM by Nicholas Allen

Comments

Monday, November 13, 2006 12:49 PM by Nicholas Allen's Indigo Blog

# When to Wait for Messages

When you call receive on a channel, there is always a timeout that bounds that receive operation. There

Saturday, November 18, 2006 9:12 AM by Sam Gentile

# New and Notable 126

I have lots of stuff collected up today. Software Architecture/SOA Arnon Rotem-Gal-Oz has made available

Saturday, October 20, 2007 3:32 PM by Sam Gentile

# New and Notable 126

I have lots of stuff collected up today. Software Architecture/SOA Arnon Rotem-Gal-Oz has made available

New Comments to this post are disabled
 
Page view tracker