Thursday 6 March 2014

Call Orchestartion Shape in Biztalk

Most of the programming languages provides a way to do nested coding. By that we can define the a block of code which is generic and may be required number of times. Once we have that defined bunch then we just need to call it wherever we want.
For example:
A()
{
   B();
}

B()
{
.
.
.
}

As you can see in above example A and B are two functions which are nested. Function A call Function B. When execution of called function(B) gets started execution of calling function(A) goes on hold. Calling function resumes it execution after completing the called function.

We have same concept in Biztalk also, we can achieve this through Call Orchestration shape in the given toolbox.
In this blow we will do following things:
Understand what is Call Orchestration.
How to Implement it(with suitable example).
Dessert.

So lets start,

What is Call Orchestration??
We can add nested Orchestration in the Biztalk. Call Orchestration shape allows us to achieve that.
We can Call other Orchestration synchronously, which means calling Orchestration waits till  called orchestration's execution gets complete.
This feature of Biztalk helps programmers to reuse the common orchestration workflow patterns across Biztalk projects.

We can pass on parameters while calling the orchestration. Parameters can be like Message, variable, port reference, role links, correlation set.




How to Implement it(with suitable example):

I have created a demo application, which uses the Call Orchestration.
Below are the steps that I  followed:
Create a Biztalk Project in Visual Studio 2010 name it "Orc_Calling".

Add one simple schema into it.(Make Price as a distinguishable field, also make sure you specify its data type as int) name it "Outer_Schema.xsd"



Then Add couple of Orchestrations in the project
1)InnerOrch.odx -- It will be the common orchestration that we will call from other orchestration.



Short description of InnerOrch.odx --

Create two Orchestration Parameters(New Message Parameter)
1)input_MsgPara
2)output_MsgPara

This orchestration is designed to check if Price of message it receive is above 500 or not.
input_MsgPara.Price > 500

We have used Construct shape which contains MessageAssignment shape. In this we set the element Status of the message, according to the Price(decide shape branches).

Below are the statement that we have in the Message Assignment:
output_MsgPara = input_MsgPara;
xpath(output_MsgPara, "//Status") = "Expensive Product";

and in other shape we have

output_MsgPara = input_MsgPara;
xpath(output_MsgPara, "//Status") = "Non-Expensive Product";

2)OuterOrch.odx -- It will be the mail orchestration that we will call to other orchestration.



Short descrption of OuterOrch.odx --  We receive a message from Receive port, then we use Call Orchestration shape to call the innerOrch orchestration.Its result is then passed to Send port.

Create two Messages of schema Outer_Schema:
1)inputMsg
2)outputMsg


Configuration of the Call Orchestration:
Right click the Call Orchestration shape and select Configure.
In Call Orchestration Configuration, select the innerOrch orchestration, and pass the two messages we have created.

Thats All we need to implement the Call Orchestration.
Build it, deploy it and Test it(Will not cover those steps here, all these steps are same as we did for other applications).

Dessert:

We can even call the orchestration from other projects.
To do that, all we need is to follow couple of simple steps:
1)set the access modifier of the (to be)called orchestration to "public". By Default orchestrations are having modifier as "internal".
2)We Need to add the reference of the project having (to be)called orchestration, in the required project.

After that you can configure the Call Orchestration in the same way as we did earlier.

**Difference Between Call and Start Orchestration**
As we know, for every orchestration Biztalk assigns a thread to it.

Start and Call orchestration differs in following ways:
1) Calling Orchestration uses same thread to execute the another orchestration.
whereas Start Orchestration, Biztalk creates new thread to execute the other orchestration.

2) Call orchestration returns the control after its execution to the calling orchestration, hence it is a synchronous way.
whereas in Start Orchestration, starts the execution in non deterministic way, hence it is a synchronous way.

3) Call Orchestration Reduces the latency, as message does not go via messagebox.
whereas Start Orchestration increases the latency as message travels via message box.

1 comment:

  1. I have followed all the above step, but I am getting error like - error X2110: use of unconstructed message 'OutputMessage'

    ReplyDelete