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

Comments

  • Anonymous
    February 02, 2006
    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

  • Anonymous
    February 06, 2006
    I've tried this today and works for both, orchestartions and send ports.

  • Anonymous
    March 26, 2006
    Cool stuff David!

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


  • Anonymous
    April 04, 2006
    I had the same problem.
    I solved it calling an other orchestration inside the loop. The called orchestration can initialize the correlation set.

  • Anonymous
    April 10, 2006
    The comment has been removed

  • Anonymous
    June 02, 2006
    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?

  • Anonymous
    October 14, 2006
    Great trick... thats what I was looking for exactly... Thanks.

  • Anonymous
    November 02, 2006
    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?

  • Anonymous
    March 23, 2007
    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

  • Anonymous
    June 28, 2007
    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

  • Anonymous
    July 24, 2007
    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.

  • Anonymous
    August 22, 2007
    Great post. Helped my cause a great deal.

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

  • Anonymous
    March 28, 2008
    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 ;)

  • Anonymous
    June 12, 2008
    I couldn't get this to work in 06 either. I'm using BTS06 R2. Guess I'll try the pipeline method!

  • Anonymous
    July 21, 2008
    Property Promotion inside Orchestration

  • Anonymous
    July 29, 2008
    Property Promotion inside Orchestration

  • Anonymous
    January 21, 2009
    PingBack from http://www.keyongtech.com/330969-problem-using-promotedproperties-and-correlationsets