Check out my new blog at

Saturday, March 08, 2008

Microsoft Project Server 2007 Queue System: Monitoring & Administration Tool Part II

In my previous post, I mentioned my itty bitty tool I built for monitoring and managing the Microsoft Project 2007 queue system.   Today, amidst my ongoing migration challenges, I continued to work the problem.   The tool consists of three primary subsystems:  the Queue Manager task bar (bottom right of the image below), the QueueManager class in play in the background, and the Queue View (the form below with the tree control to the left).  

The Queue Manager sits above the system task bar or resides in the system tray.  It has two threads:  a UI thread and a background thread queries the PSI's queue web service.    The Queue Manager communicates with its background thread via a couple of thread synchronization events to allow for stopping, pausing, and resuming monitoring of the queue as well handling updating the Queue View UI (discussed below)  .  Clicking the little book icon brings up the Queue View, which has two (and soon three) tabs:  Live View, Queue View, and soon the Configuration View.


The background thread spawned by the UI thread makes a call into QueueManager.BeginMonitoring to start monitoring.   Monitoring is done by calling ReadAllJobStatuses on the PSI queue web service at an interval specified by the user.  Also specified by the user is the job status and message types to look at.  An interesting aspect of the monitoring machinery is that it records a queue job's traversal through the job lifecycle, which you can see in the above example:  SendIncomplete, ReadyForProcessing, and Success.  Because of the relative speed at which jobs are dequeued and processed, a lifecycle step may not get picked up (such as the example above where the Processing job state happened too quickly to get picked up).

The original UI thread works to process messages on the small window hovering above the task bar (lower left in the image below).  The background processor thread does the work of querying the queue web service.   The Queue View runs on the original UI thread.  The problem here is that the "resolution" of job information requires separate calls to the PSI to associate the queue status resource GUID and other elements to the human readable data displayed in the grid to the right of the tree control.  I got a little thread happy by adding a third thread that resolves the queue status information separate from the primary UI thread and the background thread.  A thread count appropriate to the problem domain and the local processor capabilities remains an important decision and in this case I disregarded some of the criteria for thread count in order to experiment with threading.  In particular, I wanted the background thread to focus on querying the queue for status as rapidly as possible so I could see the job lifecycle in action.   To pause on the thread to make additional calls to the PSI caused many job states to be lost as the queue is quickly processed.

The third thread is the job resolution thread that makes those additional calls to the PSI and then hands the resolved job data to the primary UI thread so the UI thread can update the Queue View.  The shared data structure is implemented as a CLI queue generic collection.  After the job resolution thread does its work, which results in a job with all the relevant data available for human consumption, it enqueues the ResolvedJob on a shared queue (shared between the job resolution thread and the UI thread).   The queue is protected by a ReaderWriteLock.  The UI thread waits on a manual reset event that is signaled by the job resolution thread once one or more new jobs are enqueued (the enqueue requires the thread to take a reader-writer lock).  Once signaled, the UI thread obtains a reader lock and dequeus the new jobs and updates the Queue View.

The overall effect of this strategy is good processor usage, continuous monitoring of the Project Queue, and great UI responsiveness. 

I am pausing this coming week to work another project, which is also project management related so I hope to blog on that. 

Have a good weekend.

1 comment :

Anonymous said...

Thanks for the auspicious writeup. It in reality was a leisure account it.
Glance complicated to more introduced agreeable from you!
By the way, how could we communicate?

Also visit my web site: daily offers


Content on this site is provided "AS IS" with no warranties and confers no rights. Additionally, all content on this site is my own personal opinion and does not represent my employer's view in any way.