In the sequence of my last two posts (here and here) and following the same topic, in order to finalize it, let’s talk about the last option and see how we can accomplish the same goal but this type configuring the Send Handler for existing static Send Ports in your environment.
Well, the two previous posts are, in my opinion, more critical than this one for the simple reason that the default BizTalk installation will have ports in your environment that need to be configured if you want to configure BizTalk Host in a High Availability way, i.e., dedicate logical hosts to run specific areas of functionality such as receiving messages, sending messages, processing orchestrations or tracking data.
However, and although less critical, static send ports can also be a problem in some scenarios, for example:
- If you install ESB Toolkit before configuring your hosts for each functionality, because, during the ESB Toolkit installation it will also be created a static send port call “ALL.Exceptions” that connects with SQL “EsbExceptionDb” database. And this port will be configured with the default send handler (at that time) configured in your environment, that is by default the “BizTalkServerApplication”
- but also if you reach to an existing environment, already containing several BizTalk Applications running, that is not configured according to best practices in terms of host and host instances (dedicate logical hosts for each functionality).
Once again, we need to do basically do the same steps described in my last two posts to accomplish the task of deleting “BizTalkServerApplication”, this time as a send handler of each adapter:
- Manually reconfigure the Send handler for each the existing Static Send Port first, configuring them with the new or correct Send Handler;
- and then manually delete the “BizTalkServerApplication” as a Send handler for each adapter;
You may have heard this before, but it never hurts, all of these tasks are time-consuming, and a little boring to do after a while or if we need to do it several times;
So how can we automate tasks? and reuse them whenever necessary and at the same time save significant time for other tasks?
Using PowerShell is a good option :). Windows PowerShell is a Windows command-line shell designed especially for system administrators and can be used by BizTalk administrators to help them in automating repetitive tasks or tasks that are time-consuming to perform manually.
This is a simple script that allows you to configure the Send handler associated with all the existing Static Send Ports in your environment independently of the adapter that is configured:
$catalog = New-Object Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer $catalog.ConnectionString = "SERVER=$bizTalkDbServer;DATABASE=$bizTalkDbName;Integrated Security=SSPI" foreach($SendPort in $catalog.SendPorts) { # For each receive location in your environment if($sendPort.IsDynamic -eq $False) { # Let's look for send handlers associated with Adapter configured in the send port foreach ($handler in $catalog.SendHandlers) { # if the Send Handler is associated with the Adapter configured in the send port if ($handler.TransportType.Name -eq $sendPort.PrimaryTransport.TransportType.Name) { # We will configured the port with the default send handler associated in each adapter in you system # independently if it is "BizTalkServerApplication" or not. # Note: it's is recomended that you first configure the default send handlers for each adapter # and also not to use the "BizTalkServerApplication" (my personal recomendation) if($handler.IsDefault) { $sendPort.PrimaryTransport.SendHandler = $handler break } } } } } $catalog.SaveChanges()
Prerequisites for this script: The host, host instances and Receive handlers need to be already configured in your environment before you run the script;
- Of course, this feature/behavior can be added, for example to the “PowerShell to Configure BizTalk Server 2013/2013 R2 Host and Host Instances” script that you can find in TechNet Gallery to automatically perform the creation, configuration of host, host instances and handlers for each adapter; (soon)
Download
THIS POWERSHELL IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND.
You can download PowerShell to Configure the Default Send Handler for each static Send Port from GitHub here: