Tuesday 5 May 2015

BizTalk Artefacts - Send Port Groups, Send Ports and Send Pipelines

Send Ports and Send Port Groups are subscribers of BizTalk's Message Box. They constantly look for messages intended for them in the message box.

Send Port Groups are named collection of Send Ports that BizTalk server can use to send data to multiple destination systems or locations by using one/single send port group configuration. 
Send port groups have filters (Filter 'X' in below image) which do the job of filtering messages, to allow messages whose context properties matches with the filter 'X' to go though send ports associated with it. It is optional to have a send port group in a BizTalk solution.

Send Port is the location from where BizTalk server can send (or receive in case of two way ports) data to destination system (System "B"). The Send port have a Send Adapter which takes care of the communication and transport with the destination system. Before sending the message Send Port processes the message through Send Pipeline which performs a set of operations on BizTalk message and make it ready to be sent to destination system. Send Pipeline takes one message and produces one message as output.
Just like send port groups, send ports can also have filters (Filter 'Y' in below image). Only the messages whose context properties matches with the filter 'Y' of send port, goes through it, rest of them are not picked up from Message Box.

These filters (X and Y) are static subscriptions on message box database. Subscriptions can be generated on runtime as well. When an orchestration is sending a request via two way send port and expecting a response in return. In that scenario, BizTalk internally correlates each request and its corresponding response by creating dynamic subscriptions on message box. It creates a GUID (or correlation id generated internally) while sending the message to send port and creates a subscription on runtime so that the response from that send port can be correlated and sent to the same orchestration instance which intiated that request.

What if we have a send port associated with a send port group and both of them have filters?
There can be the following there scenarios where the message in message box satisfies the filter conditions of:
  1. Send Port Group Only:  The message will be picked up by send port group from message box and will be sent to all the send port associated with it irrespective of the filter conditions on send ports.
  2. Send Port Only: The message will be picked by the send port whose filter condition matches.
  3. Send Port and Send Port Group Both: Two copies of the message will be sent as their will be two subscriptions.


Send Port Groups, Send Ports and Send Pipelines
Send Pipeline have the following three stages:
  1. Pre-assemble: This stage can contain custom components that can do any preprocessing if required before the message is serialized. This stage can have 0-255 components and they all are executed.
  2. Assemble: This stage is responsible for assembling or serializing the message to XMLs. This stage can have 0-1 component and they are all executed.
  3. Encode: This stage can host MIME/SMIME components or custom components which encodes or encrypts the message before sending it to send adapter. This stage is optional and is only used encryption is required. This stage can have 0-255 components and they all are executed.
Please provide your valuable comments below and help me in improving this article.