BizTalk Server Orchestration - Accessing Configuration from a Custom Pipeline Component

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server Orchestration > October 2005 > Accessing Configuration from a Custom Pipeline Component





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Accessing Configuration from a Custom Pipeline Component
mnagisetty

2005-10-07, 6:03 pm

I am trying to access configuration values from my custom pipeline component
but have had no luck so far. My custom component throws an exception. I
believe the exception is thrown at bool.Parse(string value).

Event Type: Error
Event Source: BizTalk Server 2004
Event Category: BizTalk Server 2004
Event ID: 5720
Date: 10/4/2005
Time: 8:23:46 AM
User: N/A
Computer: XXXXXX
Description:
There was a failure executing the send pipeline:
"Company.AppName.Messaging.SendPipelineName" Source: "mscorlib" Send Port:
"MQS://XXXX/XXXX/XXXX" Reason: Value cannot be null.
Parameter name: value


Code:
namespace Company.AppName.Components {

public class SampleComponent {
public IBaseMessage Execute(IPipelineContext pc, IBaseMessage inmsg)
{
//Determine if the switch is enabled
bool isEnabled = bool.Parse(ConfigurationSettings.AppSettings["Switch"]);

//If enabled, then set do something
if (isEnabled)
//DoSomething();

return inmsg;
}
}
}

My BTSNtSvc.exe.config file contains the following configuration settings:
<Configuration>
<AppDomains AssembliesPerDomain="10">
<DefaultSpec SecondsIdleBeforeShutdown="600"
SecondsEmptyBeforeShutdown="120">
</DefaultSpec>
<AppDomainSpecs>
<AppDomainSpec Name="AppName">
<BaseSetup>
<ConfigurationFile>G:\..\..\App.config</ConfigurationFile>
</BaseSetup>
</AppDomainSpec>
</AppDomainSpecs>
<PatternAssignmentRules>
<PatternAssignmentRule
AssemblyNamePattern="Company.AppName.Workflow.*"
AppDomainName="AppName" />
<PatternAssignmentRule
AssemblyNamePattern="Company.AppName.Components.*" AppDomainName="AppName" />
</PatternAssignmentRules>
</AppDomains>
</Configuration>

My App.Config contains the following:

<configuration>
...
...
<appSettings>
<add key="Switch" value="false" />
<add key="..." value="..." />
</appSettings>
</configuration>


I am able to read other key/value pairs in my orchestrations and their
corresponding .NET components. Can anyone tell me what I am doing wrong
here?

My current workaround for this is setting a property on the custom component
by inheriting the IPersistPropertyBag. However, this makes it difficult to
manage for our clients because it will require them to redeploy if the
property changes.

Any help would be greatly appreciated.

Thanks


Jon Flanders[MVP]

2005-10-07, 6:03 pm

I am pretty certain that the appdomain rules in the configuration file are
only for Orchestrations. Pipeline components will always run in the default
domain because they are actually created from unmanaged code. So you have
to either

a) Put the appSettings in the btsntscv.exe.config file or
b) make that a property on your pipeline component and have it be set via
the pipeline designer (which is really the "right way" for pipeline
components to persist their properties)


--
Jon Flanders
http://www.masteringbiztalk.com/blogs/jon/

"mnagisetty" <mnagisetty@discussions.microsoft.com> wrote in message
news:9D2864B6-90D5-44A9-B182-C5259BC390A4@microsoft.com...
>I am trying to access configuration values from my custom pipeline
>component
> but have had no luck so far. My custom component throws an exception. I
> believe the exception is thrown at bool.Parse(string value).
>
> Event Type: Error
> Event Source: BizTalk Server 2004
> Event Category: BizTalk Server 2004
> Event ID: 5720
> Date: 10/4/2005
> Time: 8:23:46 AM
> User: N/A
> Computer: XXXXXX
> Description:
> There was a failure executing the send pipeline:
> "Company.AppName.Messaging.SendPipelineName" Source: "mscorlib" Send Port:
> "MQS://XXXX/XXXX/XXXX" Reason: Value cannot be null.
> Parameter name: value
>
>
> Code:
> namespace Company.AppName.Components {
>
> public class SampleComponent {
> public IBaseMessage Execute(IPipelineContext pc, IBaseMessage inmsg)
> {
> //Determine if the switch is enabled
> bool isEnabled = bool.Parse(ConfigurationSettings.AppSettings["Switch"]);
>
> //If enabled, then set do something
> if (isEnabled)
> //DoSomething();
>
> return inmsg;
> }
> }
> }
>
> My BTSNtSvc.exe.config file contains the following configuration settings:
> <Configuration>
> <AppDomains AssembliesPerDomain="10">
> <DefaultSpec SecondsIdleBeforeShutdown="600"
> SecondsEmptyBeforeShutdown="120">
> </DefaultSpec>
> <AppDomainSpecs>
> <AppDomainSpec Name="AppName">
> <BaseSetup>
>
> <ConfigurationFile>G:\..\..\App.config</ConfigurationFile>
> </BaseSetup>
> </AppDomainSpec>
> </AppDomainSpecs>
> <PatternAssignmentRules>
> <PatternAssignmentRule
> AssemblyNamePattern="Company.AppName.Workflow.*"
> AppDomainName="AppName" />
> <PatternAssignmentRule
> AssemblyNamePattern="Company.AppName.Components.*" AppDomainName="AppName"
> />
> </PatternAssignmentRules>
> </AppDomains>
> </Configuration>
>
> My App.Config contains the following:
>
> <configuration>
> ...
> ...
> <appSettings>
> <add key="Switch" value="false" />
> <add key="..." value="..." />
> </appSettings>
> </configuration>
>
>
> I am able to read other key/value pairs in my orchestrations and their
> corresponding .NET components. Can anyone tell me what I am doing wrong
> here?
>
> My current workaround for this is setting a property on the custom
> component
> by inheriting the IPersistPropertyBag. However, this makes it difficult
> to
> manage for our clients because it will require them to redeploy if the
> property changes.
>
> Any help would be greatly appreciated.
>
> Thanks
>
>



mnagisetty

2005-10-07, 6:03 pm

Thanks.

I guess I have to settle with (b) which is what I am already doing.

Currently I am reading an XML document from a file within the custom
pipeline component. What kind of performance or blocking issues can I
encounter when multiple messages go through the same pipeline?


"Jon Flanders[MVP]" wrote:

> I am pretty certain that the appdomain rules in the configuration file are
> only for Orchestrations. Pipeline components will always run in the default
> domain because they are actually created from unmanaged code. So you have
> to either
>
> a) Put the appSettings in the btsntscv.exe.config file or
> b) make that a property on your pipeline component and have it be set via
> the pipeline designer (which is really the "right way" for pipeline
> components to persist their properties)
>
>
> --
> Jon Flanders
> http://www.masteringbiztalk.com/blogs/jon/
>
> "mnagisetty" <mnagisetty@discussions.microsoft.com> wrote in message
> news:9D2864B6-90D5-44A9-B182-C5259BC390A4@microsoft.com...
>
>
>

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com