This site uses cookies and by using the site you are consenting to this. We utilize cookies to optimize our brand’s web presence and website experience. To learn more about cookies, click here to read our privacy statement.

WABS Integration Patterns – Content Based Routing

Gregor Hohpe’s EAI Book (and site) has detailed information on design and implementation of enterprise integration.   In traditional BizTalk Server implementation, a framework has been created on proven orchestration design and is available on codeplex.

This blog is the first in several blog entries in which in we will describe and implement an integration pattern utilizing current on premises tools like BizTalk Server and Windows Azure BizTalk Services (WABS).

The patterns that we will address will be the most common integration patterns falling into message routing groups.

Message routing groups primarily focus on decoupling the source message that can be routed to destination message based on different set of filter conditions.

In our first scenario, we will address one of the most common integration patterns:  content based routing.  In content based routing, messages are routed to a single or multiple destinations based on the content of the message itself.  It is a core feature of most integration platforms and helps provide the framework for publish-subscribe architectures.  When using content based routing, it is often ideal to have dynamic subscriptions to allow very loosely coupled systems to be built around the process.


Contoso accepts orders for multiple brands of products they sell from many different partners in many different formats.  Contoso partners could be sending order data either via FTP in flat file or via web-services.  Along the way the message must be enriched by looking up the brand name based on a product id in the message.  Their order fulfillment is often based on one of their 2 major brands, ContosoBusiness and ContosoConsumer.  In all other cases, the orders are fulfilled regionally, so the message must also be augmented with a region as well.  This is done by looking up the region by the ShipToCustomer name.   Once the order is enriched,  ContosoBusiness orders and ContosoConsumer orders are placed in separate holding areas for further processing by the back end line of business system.   All other orders are also routed to a holding area that will be accessed by the regional fulfillment centers.  Each regional fulfillment center will then subscribe to these order messages and process them appropriately.

BizTalk Server Approach

This is one of the most common patterns within BizTalk server.  To implement this pattern as BizTalk Server Solution we would:

  1. Create a canonical order schema that promotes certain properties to the message context.
  2. For the partner that sends flat files, we would create a flat file schema and a map to the canonical order schema.
    1. We would put this on an FTP port and allow the message to be received, transformed, and published to the message box.
  3. For the partner sending us orders via a service, we would expose our schema as a WCF service and use SOAP/REST endpoints.
    1. In this case we would receive a message and pass it straight to the message box as well.
  4. Our schema has promoted properties, We would then create send ports for ContosoConsumer and ContosoBusiness and use filter expressions to pull these messages out of the message box based on the content value that was promoted.
  5. We would do the same for the regional fulfillment center.  As new regional centers are added, configuration will have to be done to add appropriate subscriptions at a later date.

WABS Integration Services Approach

We will implement the same scenario using Windows Azure BizTalk Services (WABS), creating a hybrid approach leveraging Azure service bus and On-Premises BizTalk Server SB-Messaging adapter bridging connectivity between Cloud and on-premises server.

The figure below represents a BizTalk Service Project.   We do very similar processing as in the BizTalk scenario with some different terminology and some extended features.  As can be seen, we have 2 Bridges that allow input into our process:

Pic wabs


XML bridge that allows messages to be accepted via a REST or SOAP service bus endpoint.  This bridge accepts the message in canonical form but does not do any further enrichment or transformations of message received.

The figure below shows Orderbridge configuration.

Pic wabs


Below is the canonical form of message that is received in OrderBridge.

Pic wabs


FfOrderBridge is an XML Bridge that is surfaced through an FTP Source.  The source allows a pull from an FTP site.  The bridge itself does the parsing from flat file to an XML message and runs a transformation to map it to canonical order message.

The figure  below shows the FfOrderBridge configuration.

Pic wabs

Message received on FfOrderBridge is a flat-file schema as below:


Pic wabs


Flat-file schema was created using Flat-file schema wizard for sample below:




Flat-file message received into FfOrderBridge was transformed to canonical using newer set of features and functions (List Operation, For Each and Map Each) available in BizTalk Service Mapper tool.

Pic wabs


Once the message is processed by both the bridge, it is in canonical form, at which point it is enriched.  Message enrichment is done in another XML Bridge (OrderCanonicalBridge) at which both Bridge are connected to.


OrderCanonicalBridge creates message properties by doing XPATH lookups (STCustomer, BTCustomer, Pid) and SQL Azure Lookup to determine ProductBrand (Bid) and Region (RegionId).  Product Brand is determined based on ProductId and Region is determined based on ShipToCustomer.

Following screenshot displays the OrderCanonicalBridge and all the properties that are enriched in Enrich Stage within Bridge.

Pic wabs


Xpath properties are created using the standard “Instance Xpath” property from within the Schema.

Pic wabs


SQL Azure lookup two tables are created with following definition:

CREATE TABLE [dbo].[ProductCbr](

[Id] [int] NOT NULL,

[ProductId] [char](50) NOT NULL,

[Brand] [char](100) NOT NULL,



[Id] ASC




CREATE TABLE [dbo].[RegionCbr](

[Id] [int] NOT NULL,

[ShipToCustomer] [char](150) NOT NULL,

[Region] [char](50) NOT NULL,



[Id] ASC



Two SQL Azure table lookups are performed and the properties are set for both as Bid and RegionId.   At the time of creating lookup following connection string should be used (Important to specify username as user@servername).

Database=biztalk_db;User ID=<User>@<ServerName>;

Pic wabs

Routing and Filtering

Once the enriched message exits the bridge, it is sent to one of three destinations:

  • Messages with BId=”Consumer” are routed to the Consumer queue.    Filter conditions are set on the connector between Bridge and Destination as below.

Pic wabs

  • Messages with BId=”Business” are routed to the Businessqueue.
  • All other messages are routed to a topic named Regional for further processing.  Topics give us the ability to add subscriptions on the fly and for consumers to get copies of the message for their own processing.  Once the process is put together, it can be deployed to the WABS for processing using Visual Studio Deployment.   At the time of deployment you will need to enter the secret key and the BizTalk services namespace information.

Once the artifacts are deployed, they can be viewed and verified in BizTalk Services portal as shown below:

Pic wabs

Pic wabs


The XML Bridges support tracking in three different ways:

  1. Exceptional messaging that occurs during that bridge’s processing.
  2. Tracking of message flow information.
  3. Selective tracking of properties.

The picture below shows how tracking is configured at bridge level.

Pic wabs


The user can select the properties to be tracked and whether or not to track flow data.   The tracking data can be then viewed from BizTalk Services portal for debugging and troubleshooting purpose.

Below is the detail tracking information on all the activity performed when the bridge was executed.

Pic wabs

Upon clicking on detail on one of the tracking activity, it will show the detail message information (in case below it shows the all Enriched properties that we tracked and were promoted).

Pic wabs

Pre-Requisite : 

Testing :

FTP Route:

  1. Drop FfOrder1.txt (Consumer) or FfOrder2.txt (Business) into FTP Source Location (free FTP hosting is available at DriveHq.com)
  2. FfOrderBridge will pickup the data from FTP Source
  3. FfOrder will be transformed to Canonical Order
  4. It will be sent to OrderCanonicalBridge
  5. OrderCanonicalBridge will enrich data (Xpath and Lookup) after validating data
  6. Based on the route filter condition data will be routed to appropriate queue or Topics


This example showed how the WABS are beginning to show some new and exciting features the Windows Azure Cloud can provide.  We were able to accomplish a very common scenario that is encountered with enterprise integration.  The Integration workload along with the Service Bus will provide a very robust messaging platform moving forward.  The queues and topic infrastructure gives us a much more dynamic way to route and subscribe to messages in our integration solutions.