Why messages are immutable inside Biztalk?

Posted at: 8/24/2006 at 7:12 AM by saravana
Most of us know that messages received inside biztalk are immutable, meaning they cannot be modified. If we need to modify the message say for example, if you want to change the price of the product inside the message, then a new message needs to be constructed (Inside orchestration you use Construct, Transform shape etc, inside pipeline you create a temporary stream). So, whats the reason for this immutable message behaviour. Reasons:

1. A received message might have multiple subscribers (orchestration, sendports etc) means each subscriber of a particular message references the same, single copy of that message. So, it make sense the message is not modified by any single service like Orchestration or pipelines.

2. Since single copy is referenced by multiple subscribers, it minimize storage. ( A ref counter is maintained for each message and messages with ref count of 0 are periodically removed.)

3. The concept of messages being immutable also allows for detailed tracking of message state as messages flow through the system.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:  Categories: BizTalk General
Actions: Email this article Email | Kick it! | DZone it! | Save to del.icio.us | Technorati Links
Post Information: Permanent LinkPermalink | CommentsComments(5) | Comments RSS

Comments

Thursday, January 11, 2007 6:37 AM
Saravanan
Saravanan
Hi saravana,
good explanation...but i have one doubt. We say messages are immutable but
1) we are able to promote the nodes and modify (set) their values...
2) We can access their nodes using Xpath and set the values to them...

Is my understanding correct? or iam going wrong...

please clarify.
Thursday, January 11, 2007 7:46 AM
Saravana Kumar
1. When you are promoting the nodes and modifying their values: You are actually changing the message context, but not the messags. you are reading from the message, (note, not writing) and writing it to the context.

2. For your second question, you didn't explain where you are doing using. If you are referning to Orchestration, then when you do a Contruct shape, the message will automatically be copied, you won't be modifying the original message.
Thursday, January 11, 2007 9:58 AM
Saravanan
Saravanan
Saravana,
Thanks for your reply. If we are change something in message context means, indirectly we are changing some properties associated to the message. Each and every message will be having a seperate message context rite.
Thursday, January 11, 2007 10:20 AM
Saravana Kumar
Only messages are immutable inside Biztalk not Message context. Message and Message context are two different things, changing the message context doesn't mean you are altering the message itself. I'll shown an example if you routing a message like this

<Person>
<Name>Gates</Name>
</Person>

Biztalk will have a message context associated for this message with extra properties like adapter data, url data, receive location data etc,etc as system properties. You are also allowed to add some data to the context like

PersonId = "007"

So, in the example you can see, the message remains the same, which is

<Person>
<Name>Gates</Name>
</Person>

but, the context might be changed by various factors like system properties, your properties etc.

So, we are not altering the message in anyway

HTH
Saravana
Friday, January 12, 2007 4:18 AM
Saravanan
Saravanan
Hi Saravana,
I got it finally. Thanks for clarifying..

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading