Geeks With Blogs
Evan Koch Musings on BizTalk Server and SQL Server

One of the things Microsoft introduced with BizTalk 2006 is failed message routing.  Prior to this, developers had to come up with custom solutions to remove failed messages from the messagebox to prevent them from accumulating.  Now all one has to do is enable routing for failed messages on the receive ports and create an orchestration to consume these failed messages.  When a message comes into the messagebox, BizTalk tries to find a matching subscription based on the context properties of the message.  If no matching subscriptions are found, the message is suspended.  To demonstrate this we can create a receive location and drop in a XML file.  Checking in the Group Hub we find the following:

These messages can be handled if failed message routing is enabled for the receive port that handled the message. 

The other half of this solution is to create an orchestration to handle the failed messages.  For this example we’ll write the failed messages out to the file system.  The receive port is directly bound to the messagebox.

The properties of the message in this orchestration are shown below.  Rather than specifying a schema for the message type, declaring a value of XmlDocument makes this orchestration flexible enough to consume all types of failed messages rather than restricting it to a particular schema.

The receive shape in this orchestration has a filter expression to limit it to messages with an ErrorType context property value of FailedMessage.  There are a number of context properties that are included for all messages.

With this in place, messages that do not match any subscriptions are consumed by the orchestration and written to disk.

Posted on Friday, April 4, 2008 9:13 PM | Back to top

Comments on this post: Failed Message Routing

# re: Failed Message Routing
Requesting Gravatar...
Hi Evan,

I was looking for a way to capture the cause of a failed message and read your post. I tried your method and it does write the "Message" to a folder. However, do you happens to know how I can capture the reason for the message failure and write it to a folder?


Left by Kent Ng on Sep 04, 2011 2:45 PM

# re: Failed Message Routing
Requesting Gravatar...
It really helped me...

When using the above i cannot able to see the suspended message in the Console.
Is there any way to have the Suspended Messages in the Console along with the Failure report

Left by RAJASEKHAR on Aug 01, 2012 1:53 AM

# re: Failed Message Routing
Requesting Gravatar...
Thanks it helped me to solve my problem.

Just to mention, I had to set the receive port in orchestration to Direct mode to have orchestration to work fine ;)

Left by L0uL0u on Jun 05, 2017 1:11 AM

Your comment:
 (will show your gravatar)

Copyright © Evan Koch | Powered by: