ObjectSharp Blogs

You are currently viewing

Matt Meleski's .Net Blog - The ABC's of .NET

ASP.NET/ADO.NET/Biztalk 2004/C#


Dynamically Configuring Pipeline Component Properties in a BizTalk Orchestration

This entry discusses the use of the following to programmatically alter a receive or send pipeline component(s) properties:

BTS.SendPipelineConfig
BTS.SendPipelineResponseConfig
BTS.ReceivePipelineConfig
BTS.ReceivePipelineResponseConfig

There is a link at the end of this entry to download a couple of examples.

Before discussing the above properties, two BizTalk 2006 pipeline enhancements are:

1) The execution of send and receive pipelines in orchestrations. This feature allows a receive or send pipeline to be executed without the use of a physical receive or send port.
2) Per Instance Pipeline Configuration using the BizTalk 2006 Administration Console. This allows changing the properties of receive and send pipeline components that
are set in the various stages of receive and send pipelines. The receive and send pipelines are configured to be invoked in physical receive and send ports. For example, as below the MIME/SMIME decoder pipeline component configuration of a receive pipeline can be altered on a per instance basis using the BizTalk 2006 Administration tool.

Both 1) and 2) are extremely useful features new for BizTalk 2006.

An additional feature that would be useful (in some cases) would be to alter a pipelines component property values in an orchestration.

As below the following properties may be set for a message in an orchestration.

Property                                                            Type of Port 

BTS.SendPipelineConfig                                Send Pipeline Configuration for a Two Way or One Way Send Port 
BTS.SendPipelineResponseConfig                    Receive Pipeline Configuration for a Two Way Send Port

BTS.ReceivePipelineConfig                            Receive Pipeline For a Two or One Way Receive Port
BTS.ReceivePipelineResponseConfig                Send Pipeline for a Two way Receive Port

For the below receive pipeline configured with a MIME/SMIME decoder:

The below XML is used internally by BizTalk to store the above configuration:

The above XML configuration can then be modified using a statement as below in a message assignment shape in an orchestration:

When the above altered message is sent through a physical port that is set to use a receive pipeline configured  with the MIME/SMIME component (in the decode stage):
The new configuration for the MIME/SMIME component (programmatically set in the orchestration) will then temporarily override the hardcoded configuration or the per-instance configuration pipelines configuration.

Ideally this is useful to cut down on the number of pipelines or physical send or receive ports that have to be created.

In order to use this method you can do the following:

1) Create receive or send pipelines set with the appropriate pipeline components. Deploy the pipelines. 
Note: You do not have to configure the pipeline components properties.
Note: You can also use the out of the box XML Receive or Send pipelines.

2) Create physical ports that are set to use the pipelines from 1).

3) Create and deploy orchestrations that temporarily override the hardcoded or per-instance send or receive ports pipeline configuration as was illustrated in an above graphic.
Logical ports in the orchestration are needed to send or receive the messages from an orchestration. The logical ports are then bound to physical ports. The configuration set in the orchestration will then temporarily override the configuration of the physical ports.

Note: To get a sample of the configuration for a pipeline. Do the below:
Using a tool such as Microsoft Sql Server Management Studio, query/open and copy the following values for a port created in 2), from a row in the following table.column in the BizTalkMgmtDB database:

bts_sendport.nvcSendPipelineData
bts_sendport.nvcReceivePipelineData
adm_receivelocation.ReceivePipelineData
adm_receivelocation.SendPipelineData

Note: If the column/row for a port is null, using the BizTalk Console, edit the receive or send ports pipeline configuration so that it overrides the default configuration. The configuration for the pipeline component(s) should then be set in one of the above table.column combinations. You can then revert back to the default configuration, by choosing the passthrough pipeline and then again choosing the original pipeline.
 
Note: Do not modify the contents of the rows/columns directly in the BizTalkMgmtDB database.
Note. The BizTalk Object Model could also be used to retrieve the configurations.
Note: The configuration for the pipeline can be stored and then retrieved from a configuration store (i.e. config file, SSO, database etc) and then set in the orchestration.

4) Bind the logical ports in the deployed orchestrations from 3) to physical ports from 2).

Good Things
1) This is a technique to cut down on the number of pipeline components and/or physical ports.
For example if the same XML received message was to be delivered to the same file directory i.e. (C:\flatfiles) as a delimited and positional flat file,
the following send ports, pipelines and orchestrations would be required:

Executing Send Pipelines in an Orchestration
i) Send Pipeline with FlatFile Assembler component for delimited flat file.
ii) Send Pipeline with FlatFile Assembler component for positional flat file.
iii) Send Port configured with Passthrough pipeline.
iv) Orchestration

Per Instance Pipeline Configuration
i) Send Pipeline with FlatFile Assembler.
ii) Send Port with per instance configuration of above pipeline to create delimited flat file.
iii) Send Port with per instance configuration of above pipeline to create positional flat file.
iv) Optionally an orchestration.
 
Dynamically Configuring Pipeline Component Properties in a BizTalk Orchestration
i) Send Pipeline with FlatFile Assembler.
ii) Send Port configured to use above pipeline.
iii) Orchestration


Not So Good Things
1) To dynamically configure and execute a receive pipeline, a two way send port will have to be used. This might introduce the need for a loopback adapter. A loopback adapter also introduces messagebox hops that will degrade performance.
2) Maintaining a store of the Pipeline configuration XML. The configuration store replaces individual pipeline components or per instance configuration of pipelines in a physical send or receive port.

There are two examples included in the download :
1) Orchestration sets receive pipeline configuration and uses a loopback adapter that executes altered configuration.
2) Orchestration sets send pipeline configuration and uses send file adapter to invoke altered configuration.
Note: A loopback adapter is also included in the download. Please read the ReadMe before installing


Unfortunately
I wish you could do something like the below:

OutputMessage(BTS.ReceivePipelineConfig) = "Pipeline Config XML would go here";
OutputMessage = Microsoft.XLANGs.Pipeline.XLANGPipelineManager.ExecuteReceivePipeline(typeof(PipelinesAndSchemas.ReceivePipeline), InputMessage);

It did not produce a runtime error, but the configuration for the Receive Pipeline was not overridden.

Last of All
I have yet to use this technique in a production environment. I have not tried this technique with pipelines configured to use multiple or custom components, but it should work with these scenarios. Please consider all the pros and cons of using this technique. Again, this could be an alternative to replace an unmanageable number of receive/send ports and pipelines.

 

 

 

 

Comments

  • matt October 11, 2006 5:23 PM

    The link for the download is not active.

  • matt October 11, 2006 5:34 PM

    Hi,

    There is an Objectsharp infrastructure problem with getting my files for my blogs to the correct folder on the O# server. I am working to get the files up there. Thanks for your patience.

  • matt December 11, 2006 7:45 AM

    Hi Matt, Thanks for information.
    Ya U have given in Readme notes depicting "Note: This technique should also work with BizTalk 2004".I am helpless to find out clues.Can u help me out how to configure it. As i am working with BizTalk 2004 Server.If possible can u place code...
    Thanks,
    Ram

  • matt December 11, 2006 9:07 AM

    If you can open up the sample solution in a Copy of Visual Studio 2005, then just follow the same pattern, in you Biztalk 2004 project, everything should be the same.

  • matt December 12, 2006 1:00 AM

    Hi Matt,I am unable to open the samples in my system as it has Microsoft Visual Studio .NET 2003.No conversion takes place.Just it close the solution directly.As i am working on BizTalk -2004,what steps are needed for this to resolve Can u help me out
    Thanks
    PRB

  • matt December 12, 2006 10:05 AM

    You could download the trail version of BizTalk 2006:
    And Visual Studio 2005 (the above download might come with it, not sure)

    This way you could try the sample.
    You could also try to follow the instructions in the blog. They should also apply to BizTalk 2004
    What exactly are you trying to do? If you are using BizTalk 2004 , try reading this blog. It is a custom application that does per instance pipeline configuration for BTS 2004:
    http://www.masteringbiztalk.com/blogs/jon/PermaLink,guid,2f6500ae-d832-495f-92a3-f7032ef317ca.aspx

  • Mark Brimble January 10, 2009 2:36 PM

    Matt can you call a dynamically configure pipeline component properties in a BizTalk Orchestration with out a send port configured to use the above pipeline? I tried something like;

    OutputMessage(BTS.SendPipelineConfig) = "Pipeline Config XML would go here";

    xDocCopy(BTS.SendPipelineConfig) = "Pipeline Config XML would go here";

    PipelineInput.Add(xDocCopy);

    Microsoft.XLANGs.Pipeline.XLANGPipelineManager.ExecuteReceivePipeline(typeof(PipelinesAndSchemas.SendPipeline),PipelineInput OutputMessage);

    but it did not work.

  • matt January 12, 2009 6:13 AM

    Mark, you will need a send port or receive port to execute the pipeline. ExecuteReceivePipeline will not work

  • Bram July 14, 2009 3:37 PM

    I have investigated this (using Reflector) in BizTalk 2009, but it still doesn't seem to be supported using the XLangPipelineManager: there just is NO way to set the pipeline config on the pipeline object.

    The Microsoft.BizTalk.PipelineOM.Pipeline class has a function called LoadPerInstanceConfig(), but you just can't get to it. Well, you could try re-implementing XLANGPipelineManager and using reflection to call the LoadPerInstanceConfig function (and making sure the required Stream meets all the criteria), or use Tomas Restrepo's Pipeline Testing library.

Leave a Comment

(required) 
(optional)
(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS