Easy Promotion of Context Properties

Published 07 July 05 10:43 AM | dhtoran 

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! :-)

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

# Amit Chawla said on February 2, 2006 9:11 PM:
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
# Cristian Sobral said on February 6, 2006 5:07 PM:
I've tried this today and works for both, orchestartions and send ports.
# John said on March 27, 2006 3:06 AM:
Cool stuff David!

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


# Jukka Laaksonen said on April 4, 2006 8:25 AM:
I had the same problem.
I solved it calling an other orchestration inside the loop. The called orchestration can initialize the correlation set.
# rick said on April 10, 2006 1:36 PM:
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.
# Chris Han said on June 2, 2006 9:19 AM:
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?
# Suneet said on October 14, 2006 12:40 PM:

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

# Raj said on November 2, 2006 8:55 AM:

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?

# Prasanna Krishnan said on March 23, 2007 1:07 PM:

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

# Ben Szymkow said on June 29, 2007 1:48 AM:

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

# BizUser said on July 24, 2007 12:46 PM:

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.

# Ashwani said on August 23, 2007 3:00 AM:

Great post. Helped my cause a great deal.

# Reference materials for MCTS BizTalk Server 2006 (Exam 70-235) « Sathish Krishnan’s Weblog said on February 11, 2008 9:06 AM:

PingBack from http://sathishkumarkrishnan.wordpress.com/2008/02/10/reference-materials-for-mcts-biztalk-server-2006-exam-70-235/

# Bembeng Arifin said on March 28, 2008 10:30 AM:

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 ;)

# Romie said on June 12, 2008 3:22 PM:

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

# Saravana Kumar said on July 21, 2008 11:43 AM:

Property Promotion inside Orchestration

# Saravana Kumar said on July 29, 2008 10:42 AM:

Property Promotion inside Orchestration

# Problem using PromotedProperties and CorrelationSets | keyongtech said on January 22, 2009 3:37 AM:

PingBack from http://www.keyongtech.com/330969-problem-using-promotedproperties-and-correlationsets

Leave a Comment

(required) 
(optional)
(required) 

  
Enter Code Here: Required

Search

This Blog

Syndication

Page view tracker