Search code examples
biztalkbiztalk-2013r2biztalk-orchestrations

When creating a singleton, why would the scope within the singleton be repeated?


As a follow-up to my question, I've been further looking at the design of an application that I see consistent issues with and while delving into understanding it properly (the documentation for it is outdated), I've come across a part of the orchestration that I am unclear on why it is that way.

The application is a singleton design: Here's an image of the structure of the orchestration

Now while I understand that the application is implementing a singleton-like design, I don't understand why the scope circled in red is repeated before the listen shape. I've not seen anything online that documents a design like this and I can't figure out what functionality it adds. So my question is: what function does this accomplish? Is it needed?


Solution

  • You have collapsed the first scope, so we cannot see what that contains, but you indicated that it is the same code. Usually that will be processing the first Activating message. The scope inside the listen will be for subsequent messages that match the correlation.

    Sometimes if you have a lot of duplicated code/logic, you might want to have it Call another Orchestration that contains that code/logic.

    The other option of course would be to put the process straight after the first loop, followed by the listen, which would be cleaner and remove the duplicated code. As per BizTalk Singleton Orchestration Design

    enter image description here