Biztalk Terminator

A BizTalk support tool from Microsoft that replaces terminate.vbs (mentioned in previous post).

Below is the description from the download page:

A tool which allows for common biztalk problems to be addressed by scripts provided by the biztalk team. Replaces terminate.vbs with more functionality including the ability to suspend, resume and terminate by date range. Powershell script functionality provided for performance tuning. Integration with mbvcleanupscripts.xml from the messagebox viewer utility



Cumulative Update Package for BizTalk Server 2009

Problems with BizTalk project that references another BizTalk project in Visual Studio on a computer that is running BizTalk Server 2009 (KB 977428)

The above fix is now included in the Cumulative update package 1 for BizTalk Server 2009 (KB 2429050)

Cumulative update package 1 for BizTalk Adapter Pack 2.0 (KB 2444952)

BizTalk RPC error

Came across this really annoying RPC error at a client site.  One of their systems is still running BizTalk 2004 (this problem is probably still the same in BizTalk 2006). Basically they have 4 servers in the BizTalk group:

  • 2 of them doubles as application servers and are on NLB.
  • 1 is a fileserver which doubles as the SSO Master Secret Server.
  • Last one is just a BizTalk server.

They wanted to replace one of the application servers, thus built a new server to join the BizTalk group and NLB. It all seemed to work fine except that we can’t administer BizTalk from the new server after we joined it to the NLB.  Opening BizTalk Server Administration doesn’t show all the receive and send ports. Running BizTalk Explorer at least gave error messages, though they didn’t make much sense:

“Could not retrieve transport type data for Primary Transport of Send Port ‘XXX Port’ from config store. Both SSO Servers (Primary=’SERVER1′ and Backup=’SERVER2′) failed. Backup server failure: The RPC server is unavailable.”

SERVER1 and SERVER2 are the two BizTalk servers on NLB. Neither of the two servers is the Master Secret Server, so why is it trying to connect to it? The reason it cannot communicate with the two servers on the same NLB cluster is because the NLB has been configured to use Unicast. Anyway, it shouldn’t need to communicate with either of those two servers, it just needs to communicate with the Master Secret Server.

The question is: where/what sets the SSO Primary and SSO Backup server values. Searching the BizTalk tables, I found that the SSO Primary server is set in the table adm_Group, under the column SSOServerName of the BizTalkMgmtDb database. Changing this value to the server name of the SSO Master Secret Server resolved the issue. Not sure where the SSO Backup server value is set though, not that it matters here.

Saving suspended messages in BizTalk (filtering on orchestration or port name)

Last week, I needed to save 700+ suspended messages to file. I didn’t want to go in to each instance and click ‘save to file’ 700 times. A quick search in the web did not find what I want, however there were a number of articles about extracting messages from the BizTalk tracking database. One of which is this excellent article by Thiago Almeida.

My scenario was for an existing BizTalk 2004 implementation in the company and is only a once-off thing I need to do. For the newer BizTalk 2006 applications, there is the ‘Failed Message Routing’ feature that can be enabled on send ports and receive ports. The failed messages could then be easily subscribed to a send port to output to file.

Then it occured to me that the WMI script Terminate.vbs has the option to save the messages before terminating the instances ( and slightly updated for 2009 ). Thus changing this script to do what I want required the least effort. I could just use the script as it is to save all the messages and terminate the instances. However it didn’t take much to modify it to take a parameter for filtering on an instance name and to only save messages (and not terminate them). Below is the usage description of the save_messages.vbs script and the actual script. It works for BizTalk 2004, 2006 and 2009.

There is also a replacement of the Terminate.vbs script: Biztalk Terminator.

cscript save_messages.vbs < -Z | -A | -DIS | -SR | -SNR > [Port/Orchestration name]

-Z saves all “Zombie” instances (e.g. completed with discarded messages)
-A saves all suspended and zombie instances as well as all routing failure reports
-SR saves suspended resumable instances only
-SNR saves suspended non-resumable instances only
-DIS saves all dehydrated ‘isolated adapter’ instances
optionally supply the name of the orchestration or port name to filter on specific instances

Ensure that the C:\Temp folder exists before running as that is where it saves the instances

Example: cscript save_messages.vbs -z “E-Reporting Data Transform Port”

Visual Basic Script:

‘ save_messages.vbs
‘ Enter save_messages.vbs with no arguments from a command prompt for usage
‘ This script needs to be run under a user account that is a member of the BizTalk Administrators
‘ group. This script needs to be run on a machine that is configured with BizTalk administration
‘ tools.

dim objBtsWmiNS, objMsg, svcinsts, inst, msg, ndx, size

Dim aryHostNames()
Dim aryObjQueues()
Dim aryHostBatchSize()

Dim strKey2Instance
Dim strQuery2Msg
Dim strServiceName

On Error Resume Next
Dim objArgs: Set objArgs = WScript.Arguments
If ( objArgs.Count = 0 OR objArgs.Count > 2) Then
wscript.quit 0
End If

wmiQuery = “”

‘ServiceStatus = 16 – ‘Completed With Discarded Messages’ in BizTalk Server 2004
‘ServiceStatus = 32 – ‘Suspended (not resumable)’
‘ServiceStatus = 4 – ‘Suspended (resumable)’
‘ServiceClass = 64 – ‘Routing Failure Report’
‘ErrorId = “0xC0C01B4C” – is how ‘Completed With Discarded Messages’ are exposed in BizTalk Server 2006

If (objArgs(0) = “-Z” OR objArgs(0) = “-z”) Then
wmiQuery = “select * from MSBTS_serviceinstance where ServiceStatus=16 OR ErrorId=’0xC0C01B4C'”
End If

If (objArgs(0) = “-A” or objArgs(0) = “-a”) Then
wmiQuery = “select * from MSBTS_serviceinstance where ServiceStatus=4 OR ServiceStatus=32 OR ServiceStatus=16 OR ErrorId=’0xC0C01B4C’ OR ServiceClass=64”
End If

If (objArgs(0) = “-SR” or objArgs(0) = “-sr”) Then
wmiQuery = “select * from MSBTS_serviceinstance where ServiceStatus=4”
End If

If (objArgs(0) = “-SNR” or objArgs(0) = “-snr”) Then
wmiQuery = “select * from MSBTS_serviceinstance where ServiceStatus=32”
End If

If (objArgs(0) = “-DIS” or objArgs(0) = “-dis”) Then
wmiQuery = “select * from MSBTS_serviceinstance where ServiceClass=32 AND ServiceStatus=8”
‘ServiceClass = 32 ‘Isolated Adapter
‘ServiceStatus = 8 ‘Dehydrated
End If

saveMessagesBeforeTermination = True

If ( objArgs.Count > 1) Then
strServiceName = objArgs(1)
End If

If(wmiQuery = “”) Then
wscript.quit 0
End If

wscript.echo “–>Connecting to BizTalk WMI namespace”
Set objBtsWmiNS = GetObject(“WinMgmts:{impersonationLevel=impersonate, (security)}\\.\root\MicrosoftBizTalkServer”)
If Err <> 0 Then
wscript.quit 0
End If

wscript.echo “–>Getting BizTalk host collection”
Set hosts = objBtsWmiNS.ExecQuery(“select * from MSBTS_HostSetting”)
If Err <> 0 Then
wscript.quit 0
End If

hostCount = hosts.count

ReDim aryHostNames(hostCount – 1)
ReDim aryObjQueues(hostCount – 1)
ReDim aryHostBatchSize(hostCount – 1)

wscript.echo “–>Retrieve BizTalk host names and loading host queues”
ndx = 0
For Each host in hosts
wscript.echo “Found host ” & host.Properties_(“Name”)
aryHostNames(ndx) = host.Properties_(“Name”)
Set aryObjQueues(ndx) = objBtsWmiNS.Get(“MSBTS_HostQueue.HostName=””” & aryHostNames(ndx) & “”””)
If Err <> 0 Then
wscript.quit 0
End If
ndx = ndx + 1

wscript.echo “–>Getting collection of service instances”
Set svcinsts = objBtsWmiNS.ExecQuery(wmiQuery)

‘Iterate through instances and save them in host-specific arrays.

wscript.echo “–>Start iterating service instances”
totalCount = 0
For Each inst in svcinsts
If (objArgs.Count = 1 Or (objArgs.Count > 1 And strServiceName = inst.Properties_(“ServiceName”) ) ) Then

wscript.echo “Found suspended instance “”” & inst.Properties_(“ServiceName”) & “”” on host ” & inst.Properties_(“HostName”)
‘Resolve host index
For hostIdx = 0 To hostCount-1
If aryHostNames(hostIdx) = inst.Properties_(“HostName”) Then
Exit For
End If

’16 is an internal service class that cannot be terminated
If 16 = inst.Properties_(“ServiceClass”) Then
wscript.echo “Skipping BizTalk internal service instances (they cannot be terminated anyway)”
’64 is a routing failure report and doesn’t have messages that can be saved
If 64 = inst.Properties_(“ServiceClass”) Or 16 = inst.Properties_(“ServiceClass”) Then
saveMessagesBeforeTermination = False
End If

errorCountSavingMessages = 0
If saveMessagesBeforeTermination Then
strQuery2Msg = “select * from MSBTS_MessageInstance where ServiceInstanceID=””” & inst.Properties_(“InstanceId”) & “”””
Set msgInsts = objBtsWmiNS.ExecQuery(strQuery2Msg)
For Each msg in msgInsts
msg.SaveToFile “C:\Temp”
If Err <> 0 Then
wscript.echo “Failed to save MSBTS_MessageInstance”
wscript.echo Err.Description & Err.Number
errorCountSavingMessages = errorCountSavingMessages + 1
wscript.echo “Saved message ” & msg.Properties_(“MessageInstanceID”)
End If
End If

totalCount = totalCount + 1
End If

End If

‘ Delete whatever is left
For hostIdx = 0 To hostCount-1
If aryHostBatchSize(hostIdx) > 0 Then
TerminateAccumulatedInstacesForHost hostIdx
End If

wscript.echo “SUCCESS> ” & totalCount & ” instances were found and attempted to be saved”

‘This subroutine deals with all errors using the WbemScripting object.
‘Error descriptions are returned to the user by printing to the console.
Sub CheckWMIError()

If Err <> 0 Then
On Error Resume Next
Dim strErrDesc: strErrDesc = Err.Description
Dim ErrNum: ErrNum = Err.Number
Dim WMIError : Set WMIError = CreateObject(“WbemScripting.SwbemLastError”)

If (TypeName(WMIError) = “Empty” ) Then
wscript.echo strErrDesc & ” (HRESULT: ” & Hex(ErrNum) & “).”
wscript.echo WMIError.Description & “(HRESULT: ” & Hex(ErrNum) & “).”
Set WMIError = nothing
End If

‘wscript.quit 0
End If

End Sub

Sub PrintUsage()
wscript.echo “Usage:”
wscript.echo “cscript save_messages.vbs < -Z | -A | -DIS | -SR | -SNR > [Port/Orchestration name]”
wscript.echo ”  -Z saves all “”Zombie”” instances (e.g. completed with discarded messages)”
wscript.echo ”  -A saves all suspended and zombie instances as well as all routing failure reports”
wscript.echo ”  -SR saves suspended resumable instances only”
wscript.echo ”  -SNR saves suspended non-resumable instances only”
wscript.echo ”  -DIS saves all dehydrated ‘isolated adapter’ instances”
wscript.echo ”  optionally supply the name of the orchestration or port name to filter on specific instances”
wscript.echo ”  Ensure that the C:\Temp folder exists before running as that is where it saves the instances”
wscript.echo ”  Example: cscript save_messages.vbs -z “”E-Reporting Data Transform Port”””
End Sub

BizTalk Server 2006 R3

Steven Martin announced the plan for BizTalk Server 2006 R3 to compliment the new 2008 platform of Windows Server, the .NET Framework, Visual Studio, and SQL Server. Some of the features he highlighted are:

  • New web service registry capabilities with support for UDDI (Universal Description Discovery and Integration) version 3.0
  • Enhanced service enablement of applications (through new and enhanced adapters for LOB applications, databases, and legacy/host systems)
  • Enhanced service enablement of “edge” devices through BizTalk RFID Mobile
  • Enhanced interoperability and connectivity support for B2B protocols (like SWIFT, EDI, etc)
  • SOA patterns and best practices guidance to assist our customer’s implementations

Steve Jobs’ 2005 Stanford Commencement Address

Drawing from three stories about his life, Steve Jobs delivered a moving commencement address to Stanford’s 2005 graduating class. Inspiring stuff. “Stay Hungry. Stay Foolish” 🙂

UK 2008 Microsoft Launch Event

Having taken the day off work, I woke up at 5.30 a.m. (yesterday) to catch the train to Birmingham. It was the official launch event: HEROES happen {here} for Windows Server 2008, Visual Studio 2008 and SQL Server 2008. Was rather excited about it. Not sure why they did not have a launch event in London like they did in the 2005 launch event. It would be much easier for us who are around London to attend.

We were given promotional copies of the software which included Visual Studio 2008 Standard Edition, a 1 year evaluation license of Windows Server 2008 and SQL Server 2008. Now I can ditch my VS2008 beta and start using the real thing. It is rather good of Microsoft to give away softwares to developers, this way, developers can learn and adopt new technologies more quickly.

UK Launch 2008 (Picture of the exhibition hall at ICC Birmingham taken using my Nokia phone)

If you missed the event, you can still watch the presentations and videos at the Virtual Launch Experience.