BizTalk Late Property Promotion Pipeline

Ever wished you could base your activation subscriptions on nodes within a repeating group, build your activation subscriptions using XPath functions such as sum or average, or even base you subscriptions on rules within the rules engine.  Well the below should give you a good head start on the technique…

What we’re going to do is write a very basic pipeline component that will write to a "MessageContextPropertyBase" context property using XPath then promote it.  We then base our activation subscriptions on that context property.  Simple stuff really!

Step 1 : Create a property schema and add the SalesOrderNumber field element setting its property schema base property to "MessageContextPropertyBase".  This is the non message data based context property that our pipeline component will create, populate, and promote.  It is also the context property that we will base our activation subscriptions on.

Step 2 : Create our pipeline component.  Note at the bottom the Xpath and PropertyName properties have been exposed.  They’re persisted in the Save and Load methods.  The Execute method simply runs the supplied XPath over the body part of the IBaseMessage.  The result of the XPath is then written to the context property as supplied via the property name property.


Step 3 : Place the pipeline component on a receive pipeline and set the exposed "PropertyName" and "Xpath" properties.

Step 4 : Configure the Receive Pipeline.  Don’t forget we can easily tweak the Xpath post deployment via the administration console.


That’s it!  Now we can add as many receive locations as we want and supply any number of XPaths to populate any number of context properties and add logic to our activation subscriptions via the XPath which can be easily changed post deploy.  Now lets look at a basic test scenario to prove the technique works. 

Step 1 : Setup the activation subscription to test the context property.  Note my receive is an untyped xml document direct bound to the message box.  So the subscription is purely made up by our context property.

Step 2 : This is just a basic schema I whipped up complete with maxOccurs="*" to demonstrate populating promoted properties using data from a repeating group.

Step 3 : Now lets write some XPath that our LatePromote pipeline will use to to populate our promoted context property.  What I am trying to do here is demonstrate the concept so it can be applied to your real world scenario.  It’s up to you to take the technique and apply it.

Sample 1 : Always grab the second Order.  What we are doing here is effectively basing our activation subscription on a context property promoted from within a repeating group.  Out of the box BizTalk can’t do this.


Sample 2 : Grab the Sales Order Number from the LineItem that has a quantity greater than 20.  This is just demonstrating that all the advanced XPath functions can be used in the LatePromote pipeline.


I used the following sample data,

I mentioned back in the first paragraph that we would be able to create activation subscriptions based on the result of rules in the rules engine.  Using the above pipeline you can very easily plug the rules engine in.  It’s about ten lines of code all up and I may post it in future.  There’s plenty of scope for extending the above technique to support more than one promoted property etc.

Anyways, happy BizTalking…

This entry was posted in BizTalk Server. Bookmark the permalink.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s