Geeks With Blogs

Charles Young

Following the previous post, here is a second bit of wisdom.  In the Load method of a custom pipeline component, only assign values retrieved from the property bag to your custom properties if the retrieved value is not null.  Do not assign any value to a custom property if the retrieved value is null.

This is important because of the way in which pipeline property values are loaded at run time.  If you assign one or more property values via the Admin Console (e.g., on a pipeline in a Receive Location), BizTalk will call the Load method twice - once to load the values assigned in the pipeline editor at design time and a second time to overlay these values with values captured via the admin console.  Let's say you assign a value to custom property A at design time, but not to custom property B.  After deploying your application, the admin console will display property A's value in the Configure Pipeline dialog box.  Note that it will be displayed in normal text.  If you enter a value for Property B, it will be displayed in bold text.  Here is the important bit.  At runtime, during the second invocation of the Load method, BizTalk will only retrieve bold text values (values entered directly in the admin console).  Other values are will not be retrieved.  Instead, the property bag returns null values.  Hence, if your Load method responds to a null by assigning some other value to the property (e.g., an empty string), you will override the correct value and bad things will happen.

The following code is bad:

    object retrievedPropertyVal;
    propertyBag.Read("MyProperty", out retrievedPropertyVal, 0);

    if (retrievedPropertyVal != null)
        myProperty = (string)retrievedPropertyVal;
        myProperty = string.Empty;

Remove the 'else' block to comply with the inner logic of BizTalk's approach.

Posted on Wednesday, September 14, 2011 2:48 PM BizTalk Server 2004/2006 | Back to top

Comments on this post: BizTalk Server 2010: Loading properties in custom pipeline components

# re: BizTalk Server 2010: Loading properties in custom pipeline components
Requesting Gravatar...
Hi Charles,
Great post.. thanks for it.
I have encountered the exact situation and this helped me understand why the Load() was getting called twice.
However, after a rebuild and redeployment of the solution, this behaviour got "lost" i.e. the Load() is getting called "only once". Are there situations when this double call is traded for a single call?
Left by Praveen Behara on May 22, 2013 7:31 AM

Your comment:
 (will show your gravatar)

Copyright © Charles Young | Powered by: | Join free