This post was originally published here

Content vs Context vs Message Based Routing – Confusion Assured

Content vs Context vs Message Based Routing – Confusion Assured

To quote “Enterprise Integration Pattern Book” –

The Content-Based Router examines the message content and routes the message onto a different channel based on data contained in the message. The routing can be based on a number of criteria such as existence of fields, specific field values

Most of the time I heard people use these three words as their flavour of the month and its all very confusing. Everyone has there own opinion of this terms and hell bend on trying to understand the different meaning it comes with. Adding spice to this mixture, Microsoft never gave a concrete definition on any of these terms and mostly they will talk about scenarios, where to use and when to use, but what it is, that a million dollar question. This article is not to give proper definition, but to understand its meaning. Only saving grace among those articles was from Leonid Ganeline, which
is provided below, and I kind of agree with him on the term Content and Context Based Routing.

Content-Based Routing:

This routing uses few values from message and route the message based on those values to appropriate destination or further processing.


If you receive a Loan Application through BizTalk, based on some parameter you want to accept or reject the application. Those values which you are looking for can be either distinguished or you are using XPath expression to get the values and send it to further processing. Remember I have not used the word “Promoted”. If I used Promoted variable, it will be easy to look upon and route to appropriate send port/orchestration for further processing. But once a field got promoted, it is going to attached with word “Context”. That’s where the confusion starts. I think these are the few scenarios which sits on the fence and create confusion.

Context-Based Routing:

In BizTalk term, Context is the term used to point to group of property or meta data that are created by BizTalk Adapter. This Context/Metadata property attach to the message for its whole life cycle. One caveat though, inside orchestration Context property get lost if you applied a map on received message and if you copy the message to another message, message data pay load will be copied but its context will not copied. To do that you need to copy the message context one by one and add to the context of newly created message.

In simple term, context gets lost in Message Assignment and Transform shape. To add context to the newly created message, it has to be added manually in code.

One more concept is the MessageContextPropertyBase ( Next post I will discuss this in detail, to the extend of my knowledge), which is used to get value from the message and added to the context.

Message-Based Routing:

Some weird definition of Message-Based routing from Google Search:

When a message is passed through biztalk without being processed then it is called Message Routing.

When a message is routed by BizTalk based on message Type.

Looking at the above definition 1, without message getting processed means you are not manipulating or applying any map on the message. And how those untouched message gets routed. Obviously through context of the messsage, what else right. Then it should be called as Context Based Routing.

Now comes MessageType, if I route my message based on MessageType, from where I will be getting the Message-Type from? Of course from message Context. Then it should be called as Context-Based Routing.

One more definition I keep on hearing is that if I use PassThrough Pipelines in my receive and send ports without applying Maps then it is called Message Based Routing. PassThrough Pipelines will not add lot more context properties, but still add few context properties related to Receive and Send Ports, and you will be using those to route messages. Still not convinced, that there is a concept called Message-Based Routing.

Quote from “Leonid Ganeline” and Link to the Article:

BizTalk uses the promoted properties for routing. There are two kinds of the properties: the content properties and the context properties. The content property extracts its value from inside the message, it is a value of the element or attribute. [See MSDN] The context property gets its value from the message environment. It can be the port name that receive this message, it can be the message Id, created by the BizTalk. Context properties look like the headers in the SOAP message. Actually they are not the headers but behave like headers.

Content Based Routing:

Context Based Routing: forum=biztalkgeneral

Message Based Routing: