Using ErrorReport.MessageType in BizTalk Server
This blog post is about routing error messages in BizTalk Server by filtering on ErrorReport.MessageType.
Failed message routing
Since BizTalk Server 2006 there’s the possibility of routing failed messages. This is enabled on the send port or receive port – not receive locations.
Setting this property causes BizTalk to add context to the message that fails using the ErrorReport-schema. This enables you to manage the failed message and subsequently mail the error, log it to a database, send it to SharePoint or push it to a file location.
Skip the orchestration
I like to skip orchestrations as often as I can. It causes too much overhead. When handling errors you want to stay away from unnecessary logic added to the solution. So let’s simply create a send port that subscribes to messages of our newly created type that fail and add a map to that port that transalates the failed message to a schema that can contains the log functionality.
The image below shows the input message which we want to catch and the message that logs the error to the database.
Configuring the receive location
The ErrorReport.MessageType does not get promoted by default, however. In order to filter on this property the pipeline configured for the receive location needs to have RecoverableInterchangeProcess set to true. This causes the ErrorMessage.MessageType to be promoted.
Configuring the subscribing send port
Now we’re ready to configure the send port. First we add the map to the port like in the image below.
Then set the ErrorMessage.MessageType to the type of your message (namespace followed by the hash-character and the root node name). This will cause the send port to gobble up all the failed messages of that type.
That’s pretty much all there’s to it! Happy BizTalking!