Content Based and Context Based Routing


Routing is the process of transmitting messages between various artefacts namely Receive Ports, Send Ports and Orchestration within BizTalk Messaging Engine. It can be regarded as the heart of BizTalk Messaging Engine. To route any message inside BizTalk, the message must have a promoted property associated with it.

There are two types of promoted properties based on types they are derived from namely,

  1. Message Context Property Base
  2. Message Data Property Base or Message Part Property Base

As soon as a message is received, BizTalk will automatically promote various properties such as Adapter, Receive Port and Location Details. Also, if we use Pipeline Components such as XML or Flat-File Disassembler, additional properties will be promoted such as MessageType. Such properties promoted by default by BizTalk are derived from the Message Context Property base. Routing based on these properties is called Context based Routing. And Routing based on the latter type of promoted properties is called Content based Routing.

Any Element or Attribute promoted using BizTalk Schema Editor manually is by default derived from the Message Data Property Base. Routing based on these properties is called Content based Routing.

You can find all the default context properties promoted by BizTalk engine in the “schemas” tab of “<All Artifacts>” in BizTalk Server Administration Console. 

Different Sources used for Content/Context Based Routing:

  • Based on the content of the document
  • Based on the information contained in the envelop of the document
  • Based on the configuration information from the receive location/port (which are either populated by default or by BizTalk Engine)
  • Based on the information populated through custom pipeline components
  • Based on the information populated when a correlation set is initialized inside Orchestration send ports

Different Scenarios where Context/Content based routing are used:

  • When the message is not processed but just pass-through transmitted
  • When orchestration is not used
  • When orchestration uses Direct binding logical ports

I will try to explain each type of routing with an example. 

Let us start with Content Based Routing,

Let us say that we receive purchase orders which have several fields. All the messages received are in XML format and are placed in an inbound folder for processing

We need to route messages to trading partner A and trading partner B based on the order amount. Any purchase order with Total order amount > = 1000 will be routed to trading partner A and anything with an order amount lesser than 1000 will be routed to trading partner B.

In this example we are using a property field (POTotalAmount) defined within a schema to route messages. As said earlier any elements within schema are not promoted automatically by BizTalk engine, we need to promote the required property manually (either as Distinguished Field/Property Field). In our scenario we need to promote “TotalOrderAmount” field to access it in messaging service for routing.

PurchaseOrder Schema:


Fig: 1

I am doing a quick promotion to promote the “POTotalAmount” field.

PropertySchema with promoted POTotalAmount field:


Fig: 2

In the POTotalAmount property schema, set the “PropertySchemaBase” to “MessageContextPropertyBase”.


Fig: 3

PurchaseOrder Schema with “POTotalAmount” field highlighted with property promotion


Fig: 4

I am creating a receive port and a receive location to pick up any xml messages dropped in the inbound folder

Receive Port and Receive Location Configuration:


Fig: 5


Fig: 6


Fig: 7

Two send ports needs to be created to route messages to either trading partner A or trading partner B based on the POTotalAmount.

Creating a new Static One-Way Send Port:


Fig: 8

SendPort A Configuration:


Fig: 9


Fig: 10

In Send PortA configure the Filters expression to send messages where POTotalAmount is >= 1000


Fig: 11

Also Send PortB needs to be configured to send messages where POTotalAmount<1000

SendPort B Configuration:


Fig: 12


Fig: 13


Fig: 14

Context Based Routing


As discussed earlier BizTalk messaging engine automatically promotes various properties as soon as the message is received.  Routing of messages based on the default promoted property of BizTalk rule engine is called as Context Based Routing.

Let us consider a simple example to demonstrate the property.

We are receiving “PurchaseOrder” and “CustomerInformation” from different trading partner and based on the ReceicePort name (i.e. PurchaseOrder or CustomerInformation) messages will be routed to PortA or PortB. Messages received from “PurchaseOrder” receive port will be sent to “PortA” and messages received from “CustomerInformation” receive port will be sent to “PortB”.

PurchaseOrder Schema:


Fig: 15

CustomerInformation Schema:


Fig: 16

PurchaseOrder Receive Port and Receive Location Configuration:


Fig: 17


Fig: 18


Fig: 19

CustomerInformation Receive Port and Receive Location Configuration:


Fig: 20


Fig: 21


Fig: 22

PurchaseOrder Send Port A Configuration:


Fig: 23


Fig: 24


Fig: 25

CustomerInformation Send Port B Configuration:


Fig: 26


Fig: 27


Fig: 28



One thought on “Content Based and Context Based Routing

  1. Pingback: Content vs Context vs Message Based Routing – Confusion Assured | Vijay Microsoft Technical

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s