Tallan's Technology Blog

Tallan's Top Technologists Share Their Thoughts on Today's Technology Challenges

Calling a custom pipeline programmatically from within a BizTalk Orchestration

Cesar Cordero

Interfaces often times are required to process email attachment received thru the POP3 adapter. While recently working on a project with a use case such as this we came across a requirement where the attachment not only had to be separated/detached from the email as a body part but also then had to be reformatted/transformed from a CSV file to a standard BizTalk XML message format.

Typically the best practice and approach to parsing a flat file is with the Flat File wizard using an example of your file to generate the appropriate xml schema. You would then create a custom pipeline and place a flat file dissembler component in the disassembly section configuring the component with the FF generated schema produced by the flat file wizard:

FFWizardPicforBlog

Generally the custom pipeline is placed on your receive location and processed normally thru to and into the message box with no concerns. All is good and everyone is happy!

BUT in this case the file itself is attached to an inbound email and the sequence of events require that we receive the POP3 message and then “de-batch” or separate the attachment from that inbound POP3 original message. The bottom line: we cannot use our normal approach of having the custom pipeline at the receive location IF you’d like to keep it all in one orchestration or interface. We could, after receiving the inbound email drop the file into a file folder , associate another receive location to that file folder and then consume the attachment using the custom pipeline. But many time and for many reasons that may either not be allowed or may not be a desired approach.

Calling that same pipeline from an orchestration is fairly straight forward. From within Visual Studio in your BizTalk Project you need to add a reference to the Microsoft.XLANGs.Pipeline.dll and Microsoft.BizTalk.Pipeline.dll assemblies.

addreferenceforBlog

After this is completed you’ll be able to execute a receive pipeline as follows:

ReceivePipelineOutput = Microsoft.XLANGs.Pipeline.XLANGPipelineManager.ExecuteReceivePipeline(typeof(SchemasAndPipelines.Receivecustommessage), custommessageInputInterchange);

In my specific solution the execute receive pipeline call looked like the snapshot below:

specificsolutionBlog

Notice the receivedattachments variable. It is of the type: Microsoft.XLANGs.Pipeline.SendPipelineInputMessages

Please note to get all messages coming out the pipeline, you’ll have to loop over the batch and get all messages like this:

ReceivePipelineOutput.GetCurrent(MyOrdersInputMsg);

and in my example I in the picture above I use ReceivePipelineAttachment.MoveNext();

As mentioned above For the execution of a send pipeline you’ll need to create a variable of type Microsoft.XLANGs.Pipeline.SendPipelineInputMessages. Then call the method add on this variable which adds message of type

Microsoft.XLANGs.BaseType.XLANGMessage.SendPipelineInputMessages.Add(OrderSummary);

 

To execute the send pipeline, you’ll have call the ExecuteSendPipeline method with the just created SendPipelineInputMessages and the output message as follows:

Microsoft.XLANGs.Pipeline.XLANGPipelineManager.ExecuteSendPipeline(typeof(SchemasAndPipelines.SendCustOrdersPipeline), SendPipelineInput, OrdersOutputInterchange);

This will execute the pipeline with the default settings.

Related Articles

1 Comment. Leave new

Hello,

Is there a way in which one can change the properties of a Custom Pipeline component from outside of the BTS environment.

I basically want to run a Unit Test Method to test my Pipeline component and I have a few custom properties defined whose value I want to change.

Regards,
Jay

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

\\\