次の方法で共有


BizTalk Orchestrations, Business Rules, and Context Properties

It's always tricky to remember that messages in BizTalk Server orchestrations are immutable, and that you must construct a new message to make changes to a message body or context. However, how does the Business Rules work then? You pass a message in from an orchestration, and get a modified message out without constructing it again!

Well, in reality, the BRE actually creates a new message and sends that back to the calling orchestration. Therefore, the existing one really gets overwritten, so, be aware of that when you set context properties. If you set context properties on a message, then pass that message into a business rule, those properties disappear. I ran a quick test to make sure this was true.

So this orchestration below sets up the SMTP.Subject context property on the message, and then calls a rule to set some additional message fields up. Finally, I send the message out through the SMTP adapter. As expected, the message shows up in my mailbox without a subject (actually, the message GUID was entered as the subject).


If I add a Construct shape after the Call Rules shape and reset the SMTP.Subject, then when the message is sent out through the adapter, the mail shows up in my Inbox with the dynamically set subject line.

So, be careful when setting context properties for dynamic behavior if you are also using the BRE. It's probably a best practice to set context properties as late in the process flow as possible (i.e. directly before a Send shape).

Comments

  • Anonymous
    June 23, 2006


    Just a bit over a year since I started BizTalk blogging, so I thought I'd take 5 minutes and review...
  • Anonymous
    August 22, 2006
    Wow. I was in the middle of working on a blog post about message construction and the Business Rules