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

5 Response to "Write your first Singleton orchestration"

  1. BizTalk newbie Says:
    December 17, 2009 at 2:56 AM

    Wonderful, thanks for posting this. Very helpful.

  2. U3 says:
    February 27, 2010 at 3:34 AM

    ur welcome

  3. Unknown says:
    January 9, 2011 at 10:47 PM

    hi,
    Its really wonderful
    You have a great knowledge
    and good explanation

    Thanks & Regards,
    kiran

  4. U3 says:
    March 1, 2011 at 7:43 AM

    thanks

  5. Mallu says:
    May 2, 2011 at 12:16 PM

    Hey ,

    any gotcas with singleton,
    1.I read there is a possibility of it erroring out and will need the BTS admin to stop and start it again

    Also the chances of messges getting suspended ?

    Did u had any o these issues?