Implementing Singleton pattern with BizTalk Orchestrations

With BizTalk Orchestrations, a new instance of the orchestration is created every time a new message arrives at the Receive Port. In a Singleton pattern only one instance should exist to handle all the messages (or events) in the system.  You can implement the singleton pattern using a simple correlation on the Receive Port name, as in figure.

 

Then in your orchestration you have two receive shapes, one to activate the orchestration, and the other inside an infinite loop (or you can put some condition on the loop so you can exit he orchestration on will, which is a good idea) that correlates to the receive port Name as in figure

 

That is all that is to it! Enjoy

Advertisements