BizTalk : Orchestration To Orchestration Call Via Direct Bound Ports For A Synchronous Process
This is a demo for calling one orchestration from another orchestration via direct bound port.
Scenario: The main orchestration calls the sub orchestration and waits upon the reply to come back from sub orchestration to continue further.Please note there is a strong binding between receiver and sender orchestrations hence if the receiver orchestration contracts or version changes at any point of time you will have to incorporate that in your sender orchestration as well.
Where: If you have to implement throttling at the orchestration level this pattern will come handy.
Logic Behind: The main orchestration refers to the contract of the sub orchestration via an assembly or directly (as I have done in this example). The main orchestration passes a unique promoted property to the sub orchestration(It can be a set of properties as well).Please ensure whatever property you are promoting has to be unique for each instance of the calling orchestration. The sub orchestration does its flow and before sending back the response it also returns the promoted property written in context of its response, back to the main orchestration. Now the main orchestration has a receive port listening on the sub orchestration response, it is following a correlation Set defined for the promoted property. Confused ? Ok, lets walk through on how this has been implemented from coding perspective and I hope you will know what I am trying to explain.
Step 1: Create a new BizTalk project and add two orchestration files there.
- MainOrchestration.odx
- SubOrchestration.odx
Define the request and response schemas for each of the orchestration. The body of the orchestration will look like this. I am not doing any complex logic here. The main orchestration creates the sub orchestration request>> sends it to the messegebox>> pick up the response from the message box>>creates its own response and sends it to a file send location. The main orchestration body will look like this.
http://psrathoud.files.wordpress.com/2014/02/orchestrationmain1.png?w=650
Step 2: We need to assign a unique property to the sub orchestration request message. I have created a property schema and will be using it to define my correlation property
. http://psrathoud.files.wordpress.com/2014/02/new1.png?w=300
Step 3: Since this unique property has to be available in the context of the sub orchestration request message it has to be promoted , we accomplish this by creating a new correlation set with the identified unique property.
Step 4: Initialize this correlation set on the send shape for sending sub orchestration request and follow it on receive shape for the sub orchestration response. write the remaining portion of Main Orchestration and you are done with it here.
Step 5: The sub orchestration will look like this.
. http://psrathoud.files.wordpress.com/2014/02/orchestrationsub1.png?w=650
Step 6: Since the sub orchestration needs to return the property which was sent by the main orchestration here also you need to create another promoted property used to store the value sent by main orchestration
. http://psrathoud.files.wordpress.com/2014/02/orchestrationsub31.png?w=650
Please note all the ports used to communicate with the sub orchestration is of direct binding type( Silly to mention but that is what I have designed this solution around) Create a file receive port and trigger your orchestration. You should be able to see the following execution.This completes the demo.
. http://psrathoud.files.wordpress.com/2014/02/orchestrationexecution1.png?w=300