Biztalk 2009 MMC snap-IN

May be many of us seen that Biztalk 2009 have issue of MMC snap-in error. specifically after the application deployment or import the config file. There are some quick fix.

Fix 1: Just referesh the Admin console, if this fail
Fix 2: Restart WMI service, if this too fail
Fix 3 : Restart DTC service, this is the last option, but surely it will and it's worked for us.

If you know any best option other than these , please leave as a comment. :-)

Thanks

Biztalk Terminator

Instead of terminate script or download script. Biztalk team recently released the tool called Biztalk terminator. it is very useful for biztalk instance termination, Message download and We can easily integrate Biztalk messagebox viewer. the can be downloaded from the below link. More info or download please follow the below link

Compare Excel column vb script

The below script compare the value in column A with column B and If particular value exist in both place that value in c, if not place the value in D
Just a Simple idea :-) .Please use it and try to improve this script

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True

Set objWorkbook = objExcel.Workbooks.Open("{path-to-excel-file")
Set objWorksheet = objWorkbook.Worksheets(1)

Set objRange = objWorksheet.Range("B1").EntireColumn
i = 1

Do Until objExcel.Cells(i, 1).Value = ""
strName = objExcel.Cells(i, 1).Value
Set objSearch = objRange.Find(strName)

If objSearch Is Nothing Then
Wscript.Echo strName & " was not found."
Else
Wscript.Echo strName & " was found."
End If

i = i + 1
Loop

IIS thread counts and web services requests

Worker process:

In iis6 and iis 7, worker process is handling all the asp.net and WCF services.

Application pool and worker process:

Each application pool have one worker process

Thread handling in iis7

Each worker processor can handle 20 threads per processor, but this can be changed by editing machine.config with parameter called autoconfig=true/false. default thread timeout is 20 minutes(relatively so high), If asmx or wcf service not accepting any new requests, we should check about thread count, if it is exceeding than 20 performance will be affected.


Thread handling in ii6:
Default thread count value is decided based on server configuration, it may vary based on server hardware and architecture.

How to check thread count:
Task manager or performance counter both are good option to check thread count.

How to find which thread causing trouble:
performance counter, processor monitor, thread dumps are best option. If we go, iis thread dumps, iisstate needs to be installed.

Advisable:
While hosting asmx or wcf services, we have to divide services and host in separate application pool. While making call with some other services, we have to do timout, if destination service, not responding particular time and that timedout needs to be logged. It is really helpful during the investigation.






VB script for Message download from Biztalk Database

Dear All,






Below is the script which is very helpful specifically download messages from Biztalk (Specifically 2009, because biztalk 2009 don't have HAT, so it is not possible to download bulk messages from biztalk Database).

I really wants to thank Shankar balaji, baskar chandran and vincent choo(he is the author of http://vincentchoo.wordpress.com/, where we took the main script and this script will download the message from biztalk db and terminate those instances). But we modified vb script will not terminate any instance,just download the message from biztalk db. We tested and it is went through success fully and now I am sharing this script with you all.

Copy the below line and paste it Savemsg.bat and save it

cscript savemsg.vbs -SR "Orchestration Name"

Copy the below script and paste it in a file called savemsg.vbs and save it

before running the script create folder "D:\savemessage\" or edit

msg.SaveToFile "D:\savemessage\" line in the script and finally you are ready to run.



' 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
PrintUsage()
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

msgbox wmiQuery

saveMessagesBeforeTermination = True

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

If(wmiQuery = "") Then
PrintUsage()
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
CheckWMIError
wscript.quit 0
End If

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

hostCount = hosts.count

wscript.echo "hostcount -> " & hostcount

ReDim aryHostNames(8)
ReDim aryObjQueues(8)
ReDim aryHostBatchSize(8)

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
CheckWMIError
wscript.quit 0
End If
ndx = ndx + 1
Next

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 8
If aryHostNames(hostIdx) = inst.Properties_("HostName") Then
Exit For
End If
Next

'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)"
Else
'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 "D:\savemessage\"
If Err <> 0 Then
CheckWMIError
wscript.echo "Failed to save MSBTS_MessageInstance"
wscript.echo Err.Description & Err.Number
errorCountSavingMessages = errorCountSavingMessages + 1
Else
wscript.echo "Saved message " & msg.Properties_("MessageInstanceID")
End If
Next
End If

totalCount = totalCount + 1
End If

End If
Next

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

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) & ")."
Else
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
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
wscript.echo " Ensure that the C:\Temp folder exists before running as that is where it saves the instances"
wscript.echo
wscript.echo " Example: cscript save_messages.vbs -z ""E-Reporting Data Transform Port"""
wscript.echo
End Sub






























Health and Activity monitoring

Service Instances and Message Views in HAT
Use the Service Instances view to see what state suspended orchestrations or pipelines are in. The Service Instances view shows you metadata about the orchestration or pipeline.
Note  Suspend Service suspends orchestrations and pipelines even when the action is performed on a message instance.
When you need to troubleshoot transport-level problems, use the Message view to see undelivered messages. The Message view shows you metadata for each message as well as for the associated service instance.
When you see a suspended service or message in the event log, start your analysis with one of the Operations views. After you locate the service, you can investigate it further by using the Service DetailsMessage Flow, or Orchestration Debugger option on the shortcut menu.
In many cases, you cannot resume a suspended message—for example, if it is corrupt. However, you can choose to save a message to disk before removing it from the Suspended queue.
If a message does get suspended, an error is sent to the transport component, which might trigger a fix. If this does not happen, you can retrieve that message body, modify it, and resubmit it through another port.
Note  HAT might not track suspended messages.
Use the Resume option to resend a failed outbound message.
Depending on the cause of the suspension, you might be able to resume suspended services. For example, if an orchestration hits a Suspend shape, or if a transport was unable to deliver a message, you can resume the instance by using the shortcut menu Resume command.
If you cannot resume the services, and you finish investigating the cause, you can terminate the instance. This removes the service from the message box. Terminating also removes any messages associated with this instance, if no other instance references them.

Service instances and messages filter options

The Service Instances and Messages views both provide the same filtering capability. Selecting a filter or filters restricts the size of the Results list. If the Results list is too large, the query will time out and no longer access the MessageBox database.
The following table describes the filters you can set.
FilterDescription
HostFilters records for service instances that are enlisted in the selected Host or All.
ClassFilters records for service instances that match the service class, which can be Orchestration or Messaging or All.
NameFilters records for the specified service name or All.
StatusFilters records where the service instance has a specified status of Suspended or Active or All.
Select Query LimitFilters by a range of dates, to a specified number of matches.