Wednesday, 13 July 2016

Custom Pipelines and Pipeline Components | BizTalk


In this article, I would brief about BizTalk Pipeline and Pipeline Component. 

All messages that flow through BizTalk Server flow through receive and send pipelines. Pipelines have different stages, and each stage can include pipeline components. Pipeline components and pipelines are two completely different entities. You build pipeline components and place them within a BizTalk pipeline. 

By default, Microsoft provides Receive and Send Pipelines 

Receive Pipeline
XMLReceive - Can receive well define XML messages and promotes properties for subscription. 
PassThruReceive - Can receive any type of messages and will not promote any BizTalk Properties 
Send Pipeline
XMLTransmit - Transmit well define XML message to destination. 
PassThruTransmit - Can send any type of message. 

Receive Pipeline has Four Stages 
  • Decode 
  • Disassemble 
  • Validate 
  • Resolve party 
Send Pipeline has Three Stages 
  • Pre-assemble 
  • Assemble 
  • Encode 
To develop a custom component for pipeline we must implement the following interfaces 
  • IBaseComponent 
  • IComponentUI 
  • IComponent 
  • IPersistPropertyBag 
  • IDisassemblerComponent 
IBaseComponent: This describes the Pipeline Component Description Property, used to specify small description about pipeline component. Description is visible on pipeline properties page at design time 

Name 
Property, used to specify name of pipeline component. Name is visible on pipeline properties page at design time. 

Version 
Property used to specify version (example 1.0.0.0) of pipeline component. Visible on pipeline properties page at design time 

IComponentUI: This helps sets the Icon for component 
Icon 
Property used to provide icon associated with pipeline component. 

Validate 
Method, this is called by pipeline designer before pipeline compilation to verify that all configuration properties are correctly set. 

IComponent: Used for specific processing/massaging of messages.

Execute(IPipelineContext pContext, IBaseMessage pInMsg) Method, this does specific processing/massaging in inbound message and produces output message to be forwarded to next stages of pipeline or message box. 

IDisassemblerComponent: Used to split or break incoming message document. 

Disassemble(IPipelineContext pContext, IBaseMessage pInMsg) 
Used to split or break incoming message document. 

GetNext(IPipelineContext pContext) 
Returns messages resulting from the disassemble method execution. 

IPersistPropertyBag: This is used to set pipeline’s design time properties 

GetClassID 
Method, retrieves the component's globally unique identifying value. 

InitNew 
Method,initializes any objects needed by the component to use the persisted properties. 

Load(IPropertyBag propertyBag, int errorLog) 
Method, used to load property from property bag. 

Save(IPropertyBag propertyBag, bool clearDirty, bool saveAllProperties) 
Method,used to save property to property bag. 

Let’s start, we assume order request contains multiple orders in a wrapper and our business process can handle 1 order at a time, hence would require to-split them as individual order request. This can be achieved by just developing a de-batch pipeline component and start receiving the order request with this pipeline component in the receive side. 

To create custom component we use class library, add reference of Microsoft.BizTalk.Pipeline.dll from the directory “C:\Program Files (x86)\Microsoft BizTalk Server 2013\Pipeline Components”. Here we would create a XML Dissembler Component for debatching the message. Implement the required interfaces (IBaseComponent,IComponentUI, IDisassembler)



Actual logical of debatching happens in the IDisassembler interface, as shown below. 
On code complete, compile and the place the dll under the directory “C:\Program Files (x86)\Microsoft BizTalk Server 2013\Pipeline Components". Thus we have created our pipeline component. Create a custom receive pipeline; then choose and load the custom debatch message from Pipeline component directory to Toolbox.
Use the component at the Disassembler Stage of the Receive Pipeline, deploy the application then configure this receive pipeline at the receive location to debatch the message at the receive side in the Admin Console.
Configure the receive location with the custom receive pipeline, start the application and test the solution by copying an XML document with structure defined by the schema inside the input folder and wait the response of the process in the output folders. 


Conclusion:
In this article, I covered the pipeline architecture in BizTalk Server. Now you can customize your own pipeline to apply for your own business scenarios. 

The video demonstration is available on the Youtube, here is the embedded video.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.