Difference between Message Context PropertyBase and Message Data PropertyBase.

You can download the entire article as a PDF document.
Difference between Message Context PropertyBase and Message Data PropertyBase

This is one of the most commonly asked Question.

Every field in the property schema will be either of Type MessageContextPropertyBase and MessageDataPropertyBase (Default)

You would have already searched about the difference in MSDN which states, MessageDataPropertyBase should be selected, if the property value is filled by the Data within the Message and MessageContextPropertyBase should be selected, if the property is filled with the Data outside the Message.

So, what is the specific advantage of MessageContextPropertyBase?

Simple answer is, it helps us in preserving the Purity of the Message.

For eg: Assume that you process some Order Messages in your Application. During the Processing, you might encounter some error Messages.

Normally, developers add a new Element to the Order Schema and Try to fill that will Error Messages, which will then be used at later part of Orchestration.

But, this is not a good approach. Schema modifications should not be done for this kind of scenarios. Rather, MessageContextPropertyBase can be effectively used to hold the values associated with every message.

In short, MessageContextPropertyBase Element can be used to hold any kind of Metadata associated with the message which can be used to process the Message.

Sample Application: (To show how it can be used)

1. Create a Simple Schema.

2. Add a Property Schema with an Element and Set the Property Schema Base to MessageContextPropertyBase as shown below.

3. Create a Simple Orchestration. Add a Receive Shape to Receive the Message (say Message_1) of Type Schema which you created in Step 1.

4. Create a new Message (say Message_2) of the same Type Schema (created in step 1). Add a Message Assignment Shape. Set the Message Constructed to Message_2. Add the following Code.

Note: Modifying a Context Property is Considered as modifying a message and hence Message Assignment Shape should be used.

Now you created a message with a Custom Context Property. You can now use this message anywhere in the Orchestration as shown below.

This Message_2 can even be passed to any Sub Orchestrations and access the Context Property there.

This way MessageContextPropertyBase helps us in retaining the Purity of Message by keeping all the metadata associated with the message as Context Properties.

Points to Consider about MessageContextPropertyBase:

1. These are written to Message Context. They are not promoted. To promote them, you have to do in a Custom Pipeline or pass the message to a send port that Initializes/Follows Correlation with the Correlation Type Set to this Property.
2. Value can be written to this Property in any Pipeline Component using the Simple Method, InMessage.Context.Promote or InMessage.Context.Write

– Shiv

Web Counters


You can download the entire article as a PDF document.
Difference between Message Context PropertyBase and Message Data PropertyBase
#1 all-in-one platform for Microsoft BizTalk Server management and monitoring
turbo360

Back to Top