EAI iPaaS

BizTalk Server 2010: Loading properties in custom pipeline components

Published on : Sep 14, 2011

Category : BizTalk Server

Charles Young

Author

Following the previous posts, 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("MyPropertyt retrievedPropertyVal, 0);
    if (retrievedPropertyVal != null)
        myProperty = (string)retrievedPropertyVal;
    }
    else
        myProperty = string.Empty;
    }

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