Showing posts with label Resume BizTalk Instances. Show all posts
Showing posts with label Resume BizTalk Instances. Show all posts

Wednesday, September 5, 2018

Resume Suspended BizTalk Instances by Powershell

Hi

Recently I had in situation where a large number of instances were stuck in BizTalk which needs to be resumed faster as possible.

Following i did,

1) Query the BizTalkMsgBoxDb database to get all suspended messages by error description

select * from [dbo].[InstancesSuspended](nolock)Where lower(nvcerrordescription) like '%SearchError%'

2) Provide the , separated list of instances to following power shell script and run the script which resumed the instances on one shot as desired.

## ServiceClass members
# Description Value
# Orchestration 1
# Tracking 2
# Messaging 4
# MSMQT 8
# Other 16
# Isolated adapter 32
# Routing failure report 64

## ServiceStatus members
# Description Value
# Ready to run 1
# Active 2
# Suspended (resumable) 4
# Dehydrated 8
# Completed with discarded messages 16
# Suspended (not resumable) 32
# In breakpoint 64

#Get a list of suspended messages with info from WMI
$suspendedMsgs = Get-WmiObject MSBTS_ServiceInstance -Namespace 'root\MicrosoftBizTalkServer' -Filter '(ServiceClass = 4 or ServiceClass = 1) and (ServiceStatus = 4 or ServiceStatus = 16 or ServiceStatus = 32)' | sort SuspendTime -Desc
# Note if you want to use the datetimes from WMI use [management.managementDateTimeConverter]::ToDateTime() to convert.
foreach($msg in $suspendedMsgs)
{
    #Replace your instances list over here needs to be resume
    $msgInstnces = "905EA5D3-2BB9-4FA0-B8BC-74BB5D44EB9D,430A863B-9C4A-47CB-8953-4F6CB80AAD75".Split(",")
    foreach($msgInstnce in $msgInstnces)
    {
        if($msg.InstanceId -eq "{" + $msgInstnce + "}")
        {
        $msg.InvokeMethod("Resume",$null)
        }
    }
}


Happy Coding!!!!!