An adapter handler is an instance of a BizTalk host in which the adapter code runs. When you specify a send or receive handler for an adapter you are specifying which host instance the adapter code will run in the context of. An adapter handler is responsible for executing the adapter and contains properties for a specific instance of an adapter.
But, for purposes of load balancing, to provide process isolation for a particular adapter handler or to providing High Availability for BizTalk Hosts and according to best practices we should strategically create dedicated logical hosts to run specific areas of functionality such as tracking, receiving messages, sending messages and processing orchestrations. You can learn more and perform this type of BizTalk Host High Availability configuration using PowerShell scripts in the following TechNet article: BizTalk Server Best Practices: Create and Configure BizTalk Server Host and Host Instances.
Nonetheless one of the major problems is if we want to also delete the “BizTalkServerApplication” as a receive handler and send handler, because, before we remove an adapter handler, we must remove or re-configure all receive locations or send ports with which it is associated.
All of these tasks are time consuming, and to be fair, they are a little boring to do after we know how to do it manually. The good news is that all of these task can easily be automated, reusable and at the same time saving significant time for other tasks... how? By, for example, using PowerShell.
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.
And all these ports, will by default during the configuration, be configured with the only existing Receive handler available at the time: “BizTalkServerApplication”, or the default Host if you already have create others.
This task may occur more often on the first time we are configuring/optimizing the environment – BizTalk Server day one – but it may be more critical 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.
This is a simple script that allows you to configure the receive handlers associated with all the existing Receive Ports in your environment that are using the SQL Adapter, but this can be easily changed to cover all the Receive Locations independently of the configured adapter:
$catalog = New-Object Microsoft.BizTalk.ExplorerOM.BtsCatalogExplorer
$catalog.ConnectionString =
"SERVER=$bizTalkDbServer;DATABASE=$bizTalkDbName;Integrated Security=SSPI"
foreach($receivePort
in
$catalog.ReceivePorts)
{
# For each receive location in your environment
foreach($recLocation
$receivePort.ReceiveLocations)
# In this case I want only Receive location that are using SQL Adapter
if
($recLocation.ReceiveHandler.TransportType.Name -eq
'SQL'
)
# Let's look for receive handlers associated with SQL Adapter
foreach ($handler
$catalog.ReceiveHandlers)
# if is a SQL Adapter Receive Handler
($handler.TransportType.Name -eq
"SQL"
# And is not BizTalkServerApplication, then configure that as the handler of the receive location
# Note: that in this case we will configure as a Receive Handler of the Receive location, the first
# receive handler that we find that is not the "BizTalkServerApplication"
# because the goal is to delete this handler
($handler.Name -ne
'BizTalkServerApplication'
$recLocation.ReceiveHandler = $handler
break
}
$catalog.SaveChanges()
Prerequisites for this script: The host, host instances and Receive handlers needs to be already configured in your environment before you run the script;
You can find and download the full PowerShell script on TechNet Gallery here: PowerShell to Configure Receive Handlers from existing Receive locations
Although less critical, static send ports can also be a problem in some scenarios, for example:
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:
foreach($SendPort
$catalog.SendPorts)
($sendPort.IsDynamic -eq $False)
# Let's look for send handlers associated with Adapter configured in the send port
$catalog.SendHandlers)
# if the Send Handler is associated with the Adapter configured in the send port
($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 recommended that you first configure the default send handlers for each adapter
# and also not to use the "BizTalkServerApplication" (my personal recommendation)
($handler.IsDefault)
$sendPort.PrimaryTransport.SendHandler = $handler
You can find and download the full PowerShell script on TechNet Gallery here: PowerShell to Configure the Default Send Handler for each static Send Port
Since BizTalk Server 2013 we have available a new feature: Configurable Dynamic Send Port Handler. Which means that, when we are creating a Dynamic Send Port, an adapter Send Handler can be configurable for every installed adapter, by default it uses the default send handler associated in each adapter. This Includes both One-Way and Solicit-Response Dynamic Ports.
This is a simple script that allows you to configure the default send handlers of each adapter associated with all the existing Dynamic Send ports in your environment:
[string] $sendHost32bits =
"BizTalkServerSend32Host"
[string] $sendHost64bits =
"BizTalkServerSendHost"
foreach($sendPort
($sendPort.IsDynamic -eq
' True'
# A Dynamic send port was found so now we need to configure the send handler as desired
# 64 bits adapters
# Changing the default send handlers of the dynamic port
$sendPort.SetSendHandler(
"FILE"
, $sendHost64bits)
"HTTP"
"MQSeries"
"MSMQ"
"SB-Messaging"
"SFTP"
"SOAP"
"WCF-BasicHttp"
"WCF-BasicHttpRelay"
"WCF-Custom"
"WCF-NetMsmq"
"WCF-NetNamedPipe"
"WCF-NetTcp"
"WCF-NetTcpRelay"
"WCF-SQL"
"WCF-WebHttp"
"WCF-WSHttp"
"Windows SharePoint Services"
# 32 bits adapters
# SMTP Supports 64 bits but I want to run in 32 because of the MIME/SMIME Encoder
"FTP"
, $sendHost32bits)
"SMTP"
You can find and download the full PowerShell script on TechNet Gallery here: PowerShell to configure Default Dynamic Send Port Handlers for each Adapter
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.