Wednesday, March 17, 2010

ContextAdder XMLReceive Pipeline Component (with BRE or XML configuration)

I came across Jon Flander's very useful ContextAdder pipeline component a while ago. I found it to be very useful. In short it's a pipeline component where

"you can place in any stage of either a Receive or Send pipeline, and you can configure it with a collection of Context properties (simple written properties or promoted properties). The component will just blindly put whatever values you configure it with into the context. This is just useful as a generic way to add properties into the Message Context when needed (and it is needed pretty often - at least I need it pretty often)."

Though I love the tool very much, I found a limitation with the tool where the number of context properties can be written/promoted has to be defined at development time ONLY. Having said that, I think it would be great if the number of context properties to be written/promoted can be configurable to any number of context properties at runtime.

In order to do that, base on Jon Flander's sample code, I created 2 Context Adder pipeline components, which base on BRE and XML configuration.

1. BRE Context Adder Pipeline Component: It calls the rule engine in the pipeline, the result of the policy will return the context properties (with namespace, key and value) to be written/promoted in the message context.

sample code and sample MSI could be found here at my hotmail skydrive

2. Context Adder Pipeline Component with XML configuration:


sample code and sample MSI could be found here at my hotmail skydrive

Here is a sample of the configuration XML. As you can see, the number of context properties to be written/promoted is highly configurable. New property could be added/removed anytime during run time.

<tns:ContextAdder xmlns:tns="http://GML.BizTalk.ContextAdder.Schemas" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <tns:ContextProperties>
  <tns:ContextProperty>
   <tns:Key>EnableOrchestrationDebug</tns:Key>
   <tns:Namespace>http://GML.BizTalk.PropertySchemas.DebugFlag</tns:Namespace>
   <tns:Value>true</tns:Value>
   <tns:PromteProperty>true</tns:PromteProperty>
  </tns:ContextProperty>
  <tns:ContextProperty>
   <tns:Key>EnableAllDebug</tns:Key>
   <tns:Namespace>http://GML.BizTalk.PropertySchemas.DebugFlag</tns:Namespace>
   <tns:Value>true</tns:Value>
   <tns:PromteProperty>true</tns:PromteProperty>
  </tns:ContextProperty>
  <tns:ContextProperty>
   <tns:Key>EnablePipelineDebug</tns:Key>
   <tns:Namespace>http://GML.BizTalk.PropertySchemas.DebugFlag</tns:Namespace>
   <tns:Value>true</tns:Value>
   <tns:PromteProperty>true</tns:PromteProperty>
  </tns:ContextProperty>
 </tns:ContextProperties>
</tns:ContextAdder>

3 comments:

  1. Nice extensions! I'd encourage you to create a project on CodePlex.com where you can maintain and share these components. People will find them much more easily and the issue tracking, discussion and other tools on CodePlex will be beneficial if you plan to continue sharing and improving these components. Thanks!
    -- Tom

    ReplyDelete
  2. Fantastic post. I've been thinking about how to make pipeline components more flexible and I wonder why I didn't think of using the BRE before. Well done.

    ReplyDelete
  3. Nice pipeline comp ! Very usefull under BizTalk 2013. Is it compatible with BizTalk 2016 ?

    ReplyDelete