BizTalk Server: Running Orchestrations in Multiple Hosts on the Same Computer
Introduction
Occasionally on the forum, a poster will ask if it’s possible to run an Orchestration in different Hosts on the same computer.
The standard answer to this question is no. But like so many things is the software world, the answer is definitely no and yes. Allow me to explain.
Technically, a BizTalk Orchestration can only be Activated in a single Host, the one to which it is bound in BizTalk Administrator. This applies to new instances activated by a subscription which means Direct Bound, Specify Later, Partner Ports and Started Orchestrations. It does not apply to Called Orchestrations.
Called Orchestrations, while having a Host binding in BizTalk Administrator, run on the same thread as the calling Orchestration even it’s its bound to a different Host.
The sample Visual Studio Solution can be found in the MSDN Code Gallery at: BizTalk: Running Orchestrations in Different Hosts
Orchestration Configuration
Our sample uses 4 Orchestrations:
- HostRouter: Received the incoming Message and Starts two Host Activator Orchestrations.
- Host1Activator: Activates in RECHOST.
- Host2Activator: Activates in SENDHOST.
- WorkerOrch: Orchestration Called by the Activators.
HostRouter
The Host Router does the initial receive, then uses the Start Orchestration Shape to start the two Activators. For illustration purposes, the Router starts both Activators. In practice, the Router should distribute the work across both Activators.
Host1Activator and Host2Activator
The activators are essentially identical except for their Type names.
Both Call Orchestration Shapes call WorkerOrchestration.
WorkerOrchestration
WorkerOrchestration is where the business process would take place.
In this example, the Message Assignment Shape simply makes a copy of the inbound message, then callout to a helper function which uses WMI to determine the Windows Service Name in which it’s executing. That value is placed in the outgoing Message.
Running the Sample
- Build and Deploy the sample Solution. Modify the binding file with local paths for the C:\Data\IN and C:\Data\OUT folders.
- Start the OrchestrationsInDifferentHosts Application in BizTalk Administrator.
- Drop a copy of the SplitHostTest Xml Message into the IN folder.
- Two instances should appear in the OUT folder.
Output
We see that even though WorkerOrchestration is bound to ORCHHOST, the two Messages were process in RECHOST and SENDHOST.
<ns0:SplitHostTest xmlns:ns0="http://OrchSplitHost.SplitHostTest">
<HostRanIn>BTSSvc$RECHOST</HostRanIn>
</ns0:SplitHostTest>
<ns0:SplitHostTest xmlns:ns0="http://OrchSplitHost.SplitHostTest">
<HostRanIn>BTSSvc$SENDHOST</HostRanIn>
</ns0:SplitHostTest>
Conclusion
It is possible to run an Orchestration in different Hosts with at least one level of abstraction. Using a Resource Dispenser Pattern (BizTalk: Resource Dispenser – Send Port Edition) we could replace the HostRouter and start the process immediately with the Activators.
BizTalk Server already does a great job of managing and balancing resources but there are scenarios where scaling across processes, even on the same computer, can provide a notable benefit (always test to prove).
See Also
Another important place to find an extensive amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki.