BizTalk Demo: Parallel Convoys
A parallel convoy enables multiple single messages to join together to achieve a required result. The set of related messages can arrive in any order, but BizTalk Server must receive all of them before starting the process.Attending Interviews : Jump on this page for a better framed definition: http://msdn.microsoft.com/en-us/library/aa546782.aspx
Now lets concentrate on our purpose “How to implement it?”
In this example we are going to design a BizTalk solution which is expecting an order XML file and an Shipment Confirmation XML file from warehouse which may come in any order. Once these two are received we need to notify the customer via an outgoing XML file (ps: A customer will not understand a XML file hence we will need to have some service in place to format the output XML and do the SMTP work and this is not in the scope of our current discussion) We are going to accomplish this by writing an orchestration with a design pattern of parallel convoys.
There are two key components to implement a parallel convoy orchestration.
- Parallel Action shape
- Correlation sets which will be initialized in all the receive shapes in the Parallel action branches.
Steps
Add three schemas for Order(Inbound message), Warehouse shipment confirmation(Inbound message) and Customer Notification(Outbound message) to your BizTalk project.
https://psrathoud.files.wordpress.com/2013/12/schemas.png?w=300&h=205
Design an orchestration per this screen. Define correlation set We are using two branches in parallel action and we need to initialize the correlation in the receive shape of both the branches. The purpose of having this initialize on both is to allow initializing of the correlation when either of the messages arrives. After the parallel shapes I have used a transform to create output message taking both the inbound message as the source of map (Check the picture below)
Orchestration:
https://psrathoud.files.wordpress.com/2013/12/orchestration.png?w=300&h=207
https://psrathoud.files.wordpress.com/2013/12/correlation.png?w=300&h=168
https://psrathoud.files.wordpress.com/2013/12/transform.png?w=300&h=209
3>Create your receive and send ports, deploy your solution and complete binding of the orchestration. Start all of them and recycle HIS.
4>Drop an incoming Order xml file in your receive location. You will see a rcv pipeline and then an orchestration service started, you will also notice the orchestration has gone into dehydrate state since it is waiting for the other xml file for shipment confirmation. Drop the shipment confirmation file. Check your admin console and you will see the orchestration has completed and the output xml file will show up in the send location.
https://psrathoud.files.wordpress.com/2013/12/adminconsole.png?w=300&h=134
https://psrathoud.files.wordpress.com/2013/12/debugger.png?w=300&h=159
Also you may want to check the subscription of this orchestration and you will notice this has two subsctiption and thats how two seperate inbound messages are not triggerring two instances but they are rather consumed by only one instance.
https://psrathoud.files.wordpress.com/2013/12/subscription.png?w=300&h=139
This completes the demo. If you need the source code or have any questions please leave me a comment with your email id and will be glad to help you out.
Note: We can put the Receive Shapes in Scope Shapes with the Timeout property set to prevent the Convoy from waiting forever in case of multiple branches.