This post was originally published here
One of the annoying thing with working with Direct Bound Ports in Orchestrations, in especially, MessageBox direct bound ports that allow us to easily implement decouple publish-subscribe design patterns, is that you may get a situation in which you get a lot of Routing Failure Report Instances in the state Suspended (not resumable).
The error-handling properties facility allows us to automated handling of messaging failures as an alternative to the traditional (now default) behavior of placing failed messages in the Suspended queue. This automated handling routes an error message to any subscribing routing destination, such as a send port or orchestration. The error message is a clone of the original message with all previously promoted properties now demoted and with selected properties related to the specific messaging failure promoted to the message context.
Normally the easy way to implement this is to create a Send Port with the following filter:
- ErrorReport.ErrorType = “FailedMessage”
Nevertheless, because we are using an orchestration with Direct Bound Ports, the orchestration will receive a PersistenceException that you can handle inside our business flow, however, is also create a Routing Failure Report Instance in the state Suspended (not resumable) without any ErrorReport property promoted
So, we cannot easily automate this kind of instances.
An alternative solution to automate this task is, inside the Error Handler, invoke a helper class library that deletes all these instances once they occur in controlled fashion way:
... using (PowerShell PowerShellInstance = PowerShell.Create()) { StringBuilder pscript = new StringBuilder(); pscript.AppendLine(@"[STRING]$SQLInstance = get-wmiobject MSBTS_GroupSetting -namespace rootMicrosoftBizTalkServer | select-object -expand MgmtDbServerName"); pscript.AppendLine(@"[STRING]$BizTalkManagementDb = get-wmiobject MSBTS_GroupSetting -namespace rootMicrosoftBizTalkServer | select-object -expand MgmtDbName"); pscript.AppendLine(@"[STRING]$BizTalkGroup = ""$SQLInstance"" + "":"" + ""$BizTalkManagementDb"""); pscript.AppendLine(@"[ARRAY]$suspendedMessages = get-wmiobject MSBTS_ServiceInstance -namespace 'rootMicrosoftBizTalkServer' -filter '(ServiceStatus=32 and ServiceClass=64 and ServiceName like ""<name_of_our_orchestration>"")'"); pscript.AppendLine(@"foreach ($msgSuspended in $suspendedMessages){"); pscript.AppendLine(@"$msgSuspended.InvokeMethod(""Terminate"",$null)}"); PowerShellInstance.AddScript(pscript.ToString()); PowerShellInstance.Invoke(); } ...
How to check terminate Suspended (not resumable) Routing Failure Report Instances with PowerShell
Using PowerShell is a good option to delete all of this kind of messages, you can send a report and delete or just simply delete it. 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.
Because was controlling the error inside the main orchestration I don’t have the need of additional report, so this is a simple script will allow you to delete all Routing Failure Report Instances suspended with the state Suspended (not resumable) from your BizTalk Server environment:
#Get all Suspended (not resumable) Routing Failure Report Instances [ARRAY]$suspendedMessages = get-wmiobject MSBTS_ServiceInstance -namespace 'rootMicrosoftBizTalkServer' -filter '(ServiceStatus=32 and ServiceClass=64)' foreach ($msgSuspended in $suspendedMessages) { $msgSuspended.InvokeMethod("Terminate",$null) }
THIS POWERSHELL SCRIPT IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND.
Terminate Suspended (not resumable) Routing Failure Report Instances PowerShell (2 KB)
Microsoft | TechNet Gallery