1. When a BizTalk host instance is started, it will call the store procedure bts_ProcessHeartbeat_
exec [dbo].[bts_ProcessHeartbeat_
Here @dwCommand=1 means Process Startup.
2. When a BizTalk host instance is stopped, it will call the same store procedure bts_ProcessHeartbeat_
exec [dbo].[bts_ProcessHeartbeat_
Here @dwCommand=2 means Process Shutdown.
3. Look at the code of the store procedure bts_ProcessHeartbeat_
4. It is easy to understand why int_ProcessCleanup_
5. The questions is why int_ProcessCleanup_
Another question is raised at this point, if a host instance process is totally hang or dead there, or it is just crashed or terminated unexpectedly without restarting, who can help to detect the situation and release these locked messages and service instances? How? Let’s continue.
6. In each running BizTalk host instance, you can see one thread as the below.
0:016> kc
ntdll!NtWaitForSingleObject
kernel32!WaitForSingleObjectEx
kernel32!WaitForSingleObject
BTSMessageAgent!CAdminCacheRefresh::OnCall
BTSMessageAgent!CThreadPoolWrapper::ThreadWorker
ntdll!RtlpWorkerCallout
ntdll!RtlpExecuteWorkerRequest
ntdll!RtlpApcCallout
ntdll!RtlpWorkerThread
kernel32!BaseThreadStart
7. The thread calls the store procedure bts_ProcessHeartbeat_
…
exec [dbo].[bts_ProcessHeartbeat_Newhost] @uidProcessID=NULL,@dwCommand=0,@nHeartbeatInterval=60
…
Here @dwCommand=0 means Process Live.
8. Look at the code of the store procedure bts_ProcessHeartbeat_
9. Let’s look at the record in the table ProcessHeartbeats and see what it is look like.
uidProcessID
nvcApplicatioName
dtCreationTime
dtLastHeartbeatTime
dtLastHeartbeatTime
4d50992e-2ae1-4bbd-9d61-b712b052b99c
BizTalkServerApplication
11/25/2009 4:52:44 AM
11/25/2009 4:52:44 AM
11/25/2009 5:02:44 AM
uidProcessID is the unique GUID for each host instance. You can get the uidProcessID for a host instance by query the UniqueId column of the table adm_HostInstance in BizTalkMGMTDb. You also can get the uidProcessID for a host instance by checking the service property “Path to Executable” of the corresponding BizTalk service in Windows Service Control Manager on a BizTalk box. For example, the following is the “Path to Executable” setting for my "BizTalkServerApplication" in my BizTalk testing box. You can see the ID is after the command line option “-btsapp”.
"C:\Program Files (x86)\Microsoft BizTalk Server 2006\BTSNTSvc.exe" -group "BizTalk Group" -name "BizTalkServerApplication" -btsapp "{4D50992E-2AE1-4BBD-9D61-B712B052B99C}"
You can note that the dtNextHeartbeatTime is about equal to (dtLastHeartbeatTime+10*HeartbeatInterval). Since the default HeartbeatInterval is about 60 seconds by default(we mentioned how to modify that interval at the above), the dtNextHeartbeatTime is about 10 minutes after the dtLastHeartbeatTime by default. Of course if the HeartbeatInterval is modified to 30 seconds, then the dtNextHeartbeatTime would be 5 minutes after the dtLastHeartbeatTime.
10. Normally the record for a specified host instance in the table ProcessHeartbeat is updated every [HeartbeatInterval] seconds through the SP bts_ProcessHeartbeat_
11. Take a look at the SQL job MessageBox_DeadProcesses_Cleanup_BizTalkMsgBoxDb, it is configured to execute the store procedure bts_CleanupDeadProcesses every minute.
12. Look at the code of the SP bts_CleanupDeadProcesses, it is simply go through the table ProcessHeartbeats and check if there is a host instance which dtNextHeartbeatTime is older than the current time. If there is, which means we already lost 10 heartbeats at least from this host instance, this host instance is then considered as dead and the store procedure int_ProcessCleanup_
If this SQL job is disabled or get a problem when it is running, BizTalk will lost the capability to detect “dead” of a host instance.
No comments:
Post a Comment
Post Your Comment...