Using Workflow Monitor: tutorial, example and analysis.

Monitoring workflows is going to become an essential functionality in almost every BPM implemented with Windows Workflow Foundation. It allows administration users to get a fast and smart track of what’s going on with their multiple running workflows. This way, they can get a better control, summarized information and customized reports about running or closed workflows.

Here is a little example on how to configure and use the Workflow Monitor, using a simple workflow launcher solution to make a brief analysis of what can Workflow Monitor do for us.

This WM is an application that let you see the running or completed workflows, all along with some information like their activities and even a design view of the selected workflows.

Getting and configuring the WM:
This WM sample comes with Windows Workflow Foundation and you get it this way:
1) Open Windows Workflow Foundation Help: Documents and Settings<user>Start MenuProgramsWindows Workflow FoundationWindows Workflow Foundation Help
2) Navigate to: Windows Workflow Foundation Samples -> Application Samples -> Workflow Monitor.

This WM can show workflows details because it reads tracking information from the tracking database, so you must have installed the out-of-box SqlTrackingService. So once you have installed WM, just follow the “Configuring the SqlTrackingService Database” steps of the Windows Workflow Foundation Help up to step 4.

Step 5 is important because adds some stored procedures to the database which WM needs. In step 5, maybe you won’t find the monitor_queries.sql file, but don’t desperate!!! Its on the WorkflowMonitor folder that you just got from the Windows Workflow Foundation Help!!!

WorkflowLauncher installing and configuration:
Download WorkflowLauncher solution from here.
In the App.config file of the WindowsApplication1 from the WorkflowLauncher solution, change the Initial catalog and Data Source properties of the ConnectionString for the SqlTrackingService type of service writing your own catalog and data source strings (Initial Catalog should be "Tracking" if you used the names suggested by the Windows Workflow Foundation Help).

Note the TrackWorkflowDefinition propery is set True!!!
Build the solution.

Making that the Workflow Monitor can see the sampleWorkflow:
You must add the WorkflowProject1 assembly to the WM folder so that it can show you the design of the workflow we are going to run:


file to WorkflowMonitorCSbinDebug folder.

Using the Workflow Monitor:
If you did the 3 last steps, we are good to go. Open the WorkflowMonitor solution, set the active solution configuration to “Debug”, build the solution and start it.
Start the WorkflowLauncher solution. The WorkflowLauncher just launch a simple sequential workflow with a delay of the amount of seconds that you enter on the textbox. You can launch workflows that last as long as you want while you analyze the WM window.

Both windows should look like this:


Turn ON the monitor by pressing the green play button on the WM window. Open the Settings window and set the Polling Interval to 500 ms. Use the WorkflowLauncher to launch a 15 seconds lasting workflow:


As you can see, as the WM reads the Tracking information stored on the SQL database, shows the workflow details including the design of it. It even shows which activities are closed and which ones are running!!!:
When the 15 seconds period finishes, the WM reads the updated information from the tracking service, which says that the workflow is done:


And that’s how you can start playing with the WM…

Some benefits:
This WM works with the SqlTrackingService, so it shows the main information that services provides. But a great advantage is that you can make your own persistence service and make your own monitor to read it.

Imagine that you could organize your workflows by type so you monitor them and see in which step is every one of them or how many of them reached some point, etc…. Possibilities are countless!!!!!

If you start a 60 seconds workflow, you close the WorkflowLauncher window (closing the Runtime) and open it again before the 60 seconds, that workflow will complete right on the 60 seconds time. That’s because when the runtime is started, the persistence services are also started so the runtime can take in count persisted but not closed workflows and continue running them.

Some issues:
Multiple Definitions of the Same Workflow Type:
The SqlTrackingService will persist the workflow markup definition the first time a new workflow type is used. However, if the definition changes and the type version remains the same a new record is not persisted in the tracking database. This will result in the monitor always showing the first definition. You should check the “Workflow” Table on the Tracking database.

Dynamic Update:
The Workflow Monitor does not recognize dynamic changes to a workflow instance. If a workflow instance is changed while executing the Activity Pane will show the correct status information but the Workflow View Pane will not show the updated workflow definition and may not show the correct highlighted activity.

So use it, make your own conclusions and tell me how it was!!!

If you are new to WWF, this simple explanation can help.

Leave a Reply