Click here to Skip to main content
15,890,845 members
Articles / Programming Languages / C#

Calling Send and Receive Pipelines from the orchestration expression shapes

Rate me:
Please Sign up or sign in to vote.
2.78/5 (2 votes)
1 Jun 2009CPOL3 min read 50.3K   7   3
Calling Send and Receive Pipelines from the orchestration expression shapes

The composed message processing integration pattern implies that a composed message individual records are split up and then routed and processed, then aggregate the response into a single message again.

In our example, we process Orders from a company, just apply a simple transformation that just counts the number of items and then summarize them into a single message again. We will use Flat files as input and output messages. Moreover, we will call the receive and send pipelines at runtime in the orchestration and process individual records from the composed message.

First, we will create flat file schemas for request and response messages from the flat file schema wizard. We have to create send and receive pipelines in which we will use Flat file assemble and Flat file disassembler components respectively. We have a header in our input flat file so we will create header schema and use it in the receive Pipeline.

Configure the header schema and document schema property of the disassembler component in the receive pipeline. Also configure the document schema property of the assembler component in the send pipeline. Keep the schemas and the pipelines project separate from the orchestrations project.

Build the Schemas and Pipelines project and then create another project containing the orchestration. In the first stage of the orchestration, call the receive pipeline to disassemble the flat file message. The input and output messages will be flat files so we have to keep the output and input messages of type System.XML.XMLDocument.

To execute the receive pipeline, we have to keep the scope of the expression shape as atomic because the pipeline can be executed in the atomic shape. Also when executing the pipeline, any failure can occur so we can keep an exception handling block which in our example dumps the message in an error folder.

The Orchestration has three steps - execute the receive pipeline, loop through each individual message and make an aggregate message response message by executing the send pipeline that assembles the individual messages.

First Step

Calling Receive Pipeline

To execute the pipeline, add a reference to the Microsoft.XLANGs.Pipeline.dll and Microsoft.BizTalk.Pipeline.dll assemblies. The pipeline is executed by the following static method:

C#
ReceivePipelineOutput = Microsoft.XLANGs.Pipeline.XLANGPipelineManager.ExecuteReceivePipeline
(typeof(ShemasAndPipelines.ReceiveCustOrdres), OrdersInputInterchange);

The method takes the type of pipeline and the input message as input parameters and returns an enumerator of type Microsoft.XLANGs.Pipeline.ReceivePipelineOutputMessages. A variable (ReceivePipelineOutput) of this type is created in the atomic scope variables. When we execute the pipeline, we can iterate through all the messages with this enumerator. Below is the code written in the execute pipeline expression shape.

Second Step

Now in the second step, iterate all the messages and save it in the input message of type flat file schema which you created from the flat file wizard (OrdersInputMsg).

C#
ReceivePipelineOutput.GetCurrent(OrdersInputMsg);

iteration

You can perform any processing during the loop in your orchestration. For e.g., you can have a correlation for sending the order for approval or route the message or save it into the database. In my scenario, I had to create a map that counts the items and map it to the destination message (OrderSummary). The output message can be added to the send pipeline by the variable SendPipelineInput of type Microsoft.XLANGs.Pipeline.SendPipelineInputMessages. And then call its static method add which takes in Microsoft.XLANGs.BaseType.XLANGMessage which is the base class for any message.

C#
SendPipelineInput.Add(OrderSummary);

OrderSummary message is constructed in the transform shape and each message is then added to a message collection of send pipeline.

Step 3

In the last step, we execute the send pipeline to assemble our collection of messages into a single composite message.

Calling Send Pipeline

The send pipeline is executed from the code given below in which ExecuteSendPipeline method is executed which takes the type of pipeline, SendPipelineInput variable which holds the collection of the output messages and the Output message of type System.XML.XMLDocument.

C#
 Microsoft.XLANGs.Pipeline.XLANGPipelineManager.ExecuteSendPipeline(typeof
(ShemasAndPipelines.SendCustOrdersPipeline), SendPipelineInput, OrdersOutputInterchange);

Build and deploy the project, also note that you need to keep the pipelines as Passthrough in the receive location as well as the send port.


technorati tags:

This article was originally posted at http://abdulrafaysbiztalk.wordpress.com?p=160

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
Qatar Qatar
I am a BizTalk Server MVP for 2010 and an active blogger and a participant on the MSDN BizTalk Server Forums. I am currently working as a BizTalk Architect at a Bank in Qatar. Before this position I worked as a Sharepoint Consultant in UAE , BizTalk Architect in Bank Saudi Fransi in Saudi Arabia and United Bank Ltd in Pakistan.

I also achieved MCTS certification in BizTalk Application development in June 2008.

Click here to check out my Blog.

SQL Server Query Notification with BizTalk Server 2009 WCF SQL Adapter.

Envelope Wrapper.

Aggregator (Sequential Convoy)

Splitter (Debatching multiple records)
Resequencer
Recipient List
Scatter and Gather using Self Correlating Port

Comments and Discussions

 
QuestionCalling ExecuteReceivePipeline from C# code Pin
aneezkunju8-Oct-14 20:28
aneezkunju8-Oct-14 20:28 
QuestionRequest response port in atomic scope Pin
pkaminiv5-Jan-14 21:33
pkaminiv5-Jan-14 21:33 
GeneralMy vote of 1 Pin
bhatt hitesh1-Aug-09 17:25
bhatt hitesh1-Aug-09 17:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.