Sunday, September 13, 2009

Write your first Singleton orchestration

Write your first Singleton orchestration

As you know In BizTalk Orchestrations, a new instance of an Orchestration is created every time a message arrives at the Receive Port. So what will be the number of orchestrations if we developed an orchestration responsible to login the user ? WOW. for each user want to login, there will be an instance of orchestration .

So How can I solve this?

Do you know that there is a singleton pattern which is a design pattern that is used to restrict instantiation of a class to one object?

Depending in this term we will build a singleton orchestration which will always be only one instance of the Orchestration

HOW !!!!!!!!

Could you please explain more?

The first message that arrives at the Receive port creates a new instance of the Orchestration (initialize the correlation). All other messages would use the same Orchestration for processing (following the correlation), all the messages which arrive at the orchestration must have common property. In our example it will the receive port name

The recipe is very simple, do the following and you will get a singleton orchestration :

1)Create a correlation type with the property BTS.ReceivePortName.

2)Create a correlation set with the correlation type created in the previous step

3)In the first Receive Shape (Activate = true), set the property "Initializing Correlation Sets" as the correlation set ,and in the Second receive , set the property "Following Correlation Sets" as the correlation type .

4)Do you remember while(true) loop , we will create a similar loop similar to this loop in our orchestration

5)The listen and delay shapes is just for Massage , in order not to let the orchestration being within the memory all the time .

You can download the whole project from here
This post had been taken from this site

No comments:

Post a Comment

FEEDJIT Live Traffic Map