Wednesday, October 10, 2012

Control Back From Start Orchestration

In order to make your "Start Orchestration" work like a "Call Orchestration" shape (that is, you send the control back to the caller orchestration), you can achieve this by means of Self-Correlating port.

Say, from OrchA you start OrchB, now when OrchB completes, you want something to be done in OrchA. To make it working, 

In OrchB, create an input orchestration port parameter with following settings:

Communication Pattern = One-Way
Communication Direction = Send

For the port type settings, you can give it any operation name and specify the messagetype on request. This messagetype will be the one that will help you to send control back from OrchB to OrchA. In my case, I created a new schema under my Schemas project by the name of Notifications that would exhibit the following XML structure

<notifications><status>SUCCESS</status></notifications>

Once your port configuration is completed, this port shall appear on the port surface in the orchestration designer view. You can then add your piece of work (whatever you want to do) in OrchB and then initialize the notifications message using a message assignment shape and then send the notifications message through this port.

In OrchA, add a new port to your port surface and select choice option "Use and existing port-type". This shall show you all the available port-types listed from within all your orchestrations. Select the port-type that you created in OrchB (in previous steps). Select the binding as Direct (Self Correlating) and Communication Direction = Receive as you will be receiving notifications message on this port.

Once all set, drop a receive shape to your orchestration designer, create a message of messagetype notifications and assign that to the Message property of the receive shape.

Now whenever orchB would send a notification message, it would be appropriately received by it's caller orchA.