How to get the status of running orchestration instances..
When you have long running business processes which runs for days, months and years, they tends to get dehydrated many a times.
There are many times when we want to get the status of running business processes, where it is, at which state it is dehydrated, at which point is it in the whole business process etc. By status here, I mean different things like
· At which stage of the business process the running instance is.
o For ex.. Is the PO approved by Manager and if it is escalated Sr. Manager etc.
· In which state the instance is
o Ready To Run
o Active
o Etc…
· At which shape the running instance is dehydrated.
Knowing at which stage of the Business Process is the running instance?
You can know at which stage your business process is, by implementing BAM. While creating the BAM view create a Progression Dimension. For more on how to create a Progression Dimension see the BizTalk Server 2006 Tutorials àTutorial 5 Business Activity Monitoring àCreate Progression Dimension
See details here
http://msdn2.microsoft.com/en-us/library/aa578100.aspx
Knowing at which State the running instance is?
WMI is a very power tool for managing BizTalk related things. These things can be done very easily using WMI. For example the following code Displays all the running instances and there state.
using System; using System.Management; using System.Windows.Forms;
namespace WMISample { public class MyWMIQuery { public static void Main() { try { ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\MicrosoftBizTalkServer", "SELECT * FROM MSBTS_ServiceInstance");
foreach (ManagementObject queryObj in searcher.Get()) { Console.WriteLine("———————————–"); Console.WriteLine("MSBTS_ServiceInstance instance"); Console.WriteLine("———————————–"); Console.WriteLine("ServiceName: {0}, InstanceID: {1}, ServiceStatus: {2}", queryObj["ServiceName"], queryObj["InstanceID"], queryObj["ServiceStatus"]); } } catch (ManagementException e) { MessageBox.Show("An error occurred while querying for WMI data: " + e.Message); } } } } |
This comes from the WMI code creator, you can download it here. http://www.microsoft.com/downloads/details.aspx?FamilyID=2cc30a64-ea15-4661-8da4-55bbc145c30e&displaylang=en
The above code shows the status of InstanceID as numbers, you can translate them as following. This table comes right from BizTalk documentation.
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 |
Knowing at which shape the running instance is dehydrated
There is a very good article on this , which you can grab it see it here http://blogs.msdn.com/biztalk_core_engine/archive/2007/03/31/hidden-gem-in-biztalk-2006-r2.aspx
In this article Lee tells about a new column added to instances table in the msgbox which shows the shape on where the Orchestration is dehydrated.
The following store procedure when given the InstanceId returns a guid and a XmlDocument. The guid is the shape at which the Orchestration has been dehydrated and XmlDocument contains all the shapes in an Orchestration. You can then make some XPath queries through the XmlDocument and find the guid to know the shape at which the Instance has been dehydrated.
GO /****** Object: StoredProcedure [dbo].[GetProcessInstanceStatus] Script Date: 12/20/2007 17:28:48 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO
CREATE PROCEDURE [dbo].[GetProcessInstanceStatus] @InstanceID uniqueidentifier AS BEGIN SET NOCOUNT ON SET TRANSACTION ISOLATION LEVEL READ COMMITTED SET DEADLOCK_PRIORITY LOW
SELECT top 1 [BizTalkDTADb].[dbo].[dta_ServiceSymbols].[txtSymbol],[BizTalkMsgBoxDb].[dbo].[Instances].[nvcLastAction] FROM [BizTalkMsgBoxDb].[dbo].[Instances],[BizTalkDTADb].[dbo].[dta_ServiceSymbols] WHERE [BizTalkDTADb].[dbo].[dta_ServiceSymbols].[uidServiceId] = [BizTalkMsgBoxDb].[dbo].[Instances].[uidServiceId] AND [BizTalkMsgBoxDb].[dbo].[Instances].[uidInstanceID] = @InstanceID
END
|