Welcome to MSDN Blogs Sign in | Join | Help

Easy Promotion of Context Properties

Abstract: I’ve been dealing with context properties, and I’ve discovered a couple of very useful tricks for promoting and routing.

some definitions:
As you’ll probably know, there are two types of properties in the context of a message: properties based on field values (MessageDataPropertyBase) and properties not based on fields (MessageContextPropertyBased). I’ll call the first ones Message Properties and the other ones Context Properties.

Message Properties based on message fields are automatically written and promoted into message context by BizTalk.
Context Properties not based on message fields can be assigned inside an orchestration using the expression Message(Property) = “value”;
One of the most interesting stuff about Context Properties is that are not tied to a concrete schema, so they can be used regardless the message type. A sample of a system context property is FILE.ReceivedFilename.

the problem of promoting context properties:
When you create a context property, not based on a message field, and you assign a value inside an orchestration, it is written, but not promoted. What does it means? it means that you cannot route the message based on this property.
Some days ago I had the situation where needed exactly this: content based routing based on a custom context property that had a value calculated inside an orchestration.

A common solution is to create a custom pipeline component that writes and promotes properties. Jon Flanders has created a good generic component to do this: the ContextAdder Pipeline Component.

the trick:
In my case, the pipeline solution is not an option, since I’m routing between orchestrations via Direct Port Binding. Also, coding a custom component to promote a property seems to complex for me…
Somebody told me a good trick to promote context properties inside an orchestration, easy and direct:
Create a CorrelationSet based on the property.
Even if you are not going to use it, when you initialize a CorrelationSet, the Orchestration engine makes the promotion of the properties involved, since correlation is just an special kind of routing.

So now I have some dummy CorrelationSets, that I call <Property>Promote_CorrelationSet

nice and easy! :-)

Published Thursday, July 07, 2005 10:43 AM by dhtoran

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Easy Promotion of Context Properties

Thursday, February 02, 2006 9:11 PM by Amit Chawla
Would send ports subscribe to properties promoted in such a way?

I have a similar situation, but want the message to be subscribed by the send port NOT another orchestration.

Any Ideas?
chawla@iprimus.com.au

# re: Easy Promotion of Context Properties

Monday, February 06, 2006 5:07 PM by Cristian Sobral
I've tried this today and works for both, orchestartions and send ports.

# re: Easy Promotion of Context Properties

Monday, March 27, 2006 3:06 AM by John
Cool stuff David!

How I can defined the CorrelationSet inside the loop. I need in each iteration to create a new one, Any ideas?


# re: Easy Promotion of Context Properties

Tuesday, April 04, 2006 8:25 AM by Jukka Laaksonen
I had the same problem.
I solved it calling an other orchestration inside the loop. The called orchestration can initialize the correlation set.

# re: Easy Promotion of Context Properties

Monday, April 10, 2006 1:36 PM by rick
unless i'm missing something, the problem with this method is that if you have two different orchs where you want to init a corr set based on the same property...you will get an error on build, corr may be initialized only once, which makes sense.  

is there some way around this, without doing a custom pipe?  thx.

# It doesn't seem work with BTS2006

Friday, June 02, 2006 9:19 AM by Chris Han
David,
I tried this method with BTS2006 beta2 I created a dummy correlation set only with one context property -InterchangeID. It doesn't get promoted. It works if I promote it in the pipeline.

Any clue?

# re: Easy Promotion of Context Properties

Saturday, October 14, 2006 12:40 PM by Suneet

Great trick... thats what I was looking for exactly... Thanks.

# re: Easy Promotion of Context Properties

Thursday, November 02, 2006 8:55 AM by Raj

I have created a custom adapter in VB .Net for receiving file. In the orchestration later I want to send a file with the same name as received. How can I do that?

# re: Easy Promotion of Context Properties

Friday, March 23, 2007 1:07 PM by Prasanna Krishnan

Just one little thing, if you have multiple fields in your correlationset then you need to initialize all the variables, it took me half a day to figure out why it was failing

Anyway thanks for the simple trip, saved me creating custom pipeline

# re: Easy Promotion of Context Properties

Friday, June 29, 2007 1:48 AM by Ben Szymkow

Thanks. The correlation promotion trick worked well for me. I was needing to route based on FILE.ReceivedFileName which does seemingly not get promoted by default.

I created a dummy Correlation Set/Type and set the send port to initialize it and the process worked swimmingly.

Cheers

Ben Szymkow

# re: Easy Promotion of Context Properties

Tuesday, July 24, 2007 12:46 PM by BizUser

I'm getting the error when doing the following.

Error is in very last of this message.

I added a new element in PropertySchema and set the PropertySchemaBase to MessageContextPropertyBase.

Then I created a dummy CorrelationSet and select the element which I created in PropertySchema as a CorrelationProperty (only one element in the CorrelationSet)

Then In my first receive shape in odx, I'm initializing the newly created correlation set.  

what I'm trying to do is retrieve the first part of the File.ReceiveFileName and assing its value to the property.

ReceivedFilePrefix = MessageRequestFromTPA(FILE.ReceivedFileName);

ReceivedFilePrefix.Substring(0,ReceivedFilePrefix.IndexOf("_"));

Then in the very end, I'm sending a message to a Direct Port (MessageBox)

MessageResponse(solutionname.PropertySchema.ReceivedFilePrefix) = ReceivedFilePrfix.

In the SendPort in MMC I filter the newly created property.  

solution Built fine and deployed.

but I'm getting an error as soon as it hit the first receive shap in odx where I'm initializting the correlation set:

ERROR:

Inner exception: Failed to initialize the correlation property name: ReceivedFilePrefix namespace: http://ProjectName.PropertySchema.PropertySchema from message: MessageRequestFromTPA.

# re: Easy Promotion of Context Properties

Thursday, August 23, 2007 3:00 AM by Ashwani

Great post. Helped my cause a great deal.

# Reference materials for MCTS BizTalk Server 2006 (Exam 70-235) &laquo; Sathish Krishnan&#8217;s Weblog

# re: Easy Promotion of Context Properties

Friday, March 28, 2008 10:30 AM by Bembeng Arifin

Hi Dave,

Thanks for the post, you just saved me ;)

Finally after wasting a day for this, but always glad to find a solution in the end ;)

# re: Easy Promotion of Context Properties

Thursday, June 12, 2008 3:22 PM by Romie

I couldn't get this to work in 06 either. I'm using BTS06 R2. Guess I'll try the pipeline method!

# Property Promotion inside Orchestration

Monday, July 21, 2008 11:43 AM by Saravana Kumar

Property Promotion inside Orchestration

# Property Promotion inside Orchestration

Tuesday, July 29, 2008 10:42 AM by Saravana Kumar

Property Promotion inside Orchestration

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker