Work-Flow sample using the Microsoft Message Queue & VB
Table of contents
Overview
Requirements
Description of components
Walk through sample
Features worth noting


Overview:

This sample is provided to show how easy it is to construct work-flow applications using Visual Basic & the Microsoft Message Queue.  Feel free to reuse or modify any/all of the code contained in this project.

The work-flow sample consists of a system simulating a simplified 'insurance claim processing' system.  Claims are entered using a VB front end.   When submitted, these claims are placed in a 'insurance claims queue.'  A second VB application allows an 'insurance claims processor' to approve the claims.   Once approved, the claims are moved to a second 'accounting queue.'  A third VB application is used to process the claims in the 'accounting' queue.  When these are approved the messages are removed from the second queue and the work-flow is complete.

A fourth application is used to administer the entire system.  It allows the creation and monitoring of the queues.


Setup

Running the Workflow sample on a single machine:

The Workflow sample can be run on a single machine, if the machine is installed with Windows NT Server. To run on a single machine: 

1.       On the server machine, install the Microsoft Windows NT 4.0 Option Pack (with MSMQ's Enterprise Controller). The Option Pack can be found on the Visual Studio 6.0 Disk 2 in the WinNToptPak directory; optionally, go to the Microsoft website (www.microsoft.com), and search for Microsoft Windows NT 4.0 Option Pack to get to the download page.  

2.       SQL Server must be installed on the machine. 

3.       Install Visual Basic 6.0 (or later). 

4.       Run the sample.  

Running the Workflow sample on an intranet:

The sample can also be run as a client application on an intranet, as long as a machine running Windows NT Server is also on the network. To run the sample on a client machine installed with Win98 or WinNT:  

1.       On the client machine, install the Microsoft Windows NT 4.0 Option Pack (with MSMQ, any configuration). The Option Pack can be found on the Visual Studio 6.0 Disk 2 in the WinNToptPak directory; optionally, go to the Microsoft website (www.microsoft.com), and search for Microsoft Windows NT 4.0 Option Pack to get to the download page.  

2.       Also on the client machine, install Visual Basic 6.0 or later.  

3.       Install the Workflow sample on the client machine.  

4.       On the server machine, install Microsoft Windows NT 4.0 Option Pack with the MSMQ Enterprise Controller (requires SQL Server).  

5.       Run the sample.  

 


Description of components:

The sample is composed of four projects:

admspt0.vbp : Sets up the queues for the sample.  Allows the viewing of queue contents.

claimsp1.vbp : Allows the submission of claims (starts the work-flow)

procsp2.vbp : Allows the processing of claims from the first queue and moves them to the second queue.

accstp3.vbp : Allows the processing of claims from the second queue (finished the work-flow).


Walk through sample: (note, each of these steps can be done on the same or different machines)

a) Setup the queues:

1. Start 'Adminster_Step0'   (admspt0.vbp)

2. Click 'Create new queues' button.

3. Specify the location of the queues in the format 'MachineName\QueueSpecifier' (no '\\' before the machine name).  If the format '.\QueueSpecifier' is used the queue will be created on the current machine.

4. Click the 'Create new queues' button.

Result: You have now created the queues for you enterprise work-flow system

b) Start some work-flow:

5. Start 'ClaimEntry_Step1' (claimsp1.vbp)

6. Modify any claim attributes you want.

7. Click the 'Submit' button.

Result: You have now submitted a message to the first message queue in your work-flow system.

 

c) Move some work-flow along in your system

8. Start 'Processing_Step2.vbp' (procsp2.vbp)

9. Select a message that you want to process from the first queue and double-click on it in the listbox.

10. Click the 'Approve' button.

Result: You have now moved a work-flow item from the first queue to the second queue.

 

d) Finish the work-flow in your system.

11. Start 'Accounting_Step3.vbp' (accstp3.vbp)

12. Select a message that you want to process from the second queue and double-click on it in the listbox.

13. Click the 'Approve' button.

Result: You have now removed the message from the second queue and completed your work-flow operation.

 


Features worth noting:

Queue GUID caching:  The support routines provided cache the GUID (Globally Unique IDentifier) of the queue locally (in the system registry).  This allows a queue to be accessed even when the machine is disconnected from the network (this is useful for things like submitting messages to the queue when offline).  This code is of general interest to people developing message queue systems.

Persisting variables in messages:  In order to allow the structured persistence of groups of variables (i.e. data) a class was introduced that stores this data in a PropertyBags (new in VB6.0!) and then allows the property-bags to be persisted/de-persisted to/from messages.  This demonstrates how easy it is to persist property bags..

Message Queue Events:  The projects contain code that allows the receiving of events from the Microsoft Message Queue.   This allows an application to be updated when new messages arrive in a specified queue.

General purpose code:  The module 'modQueueSupport' contains functions that are of general use to anyone developing message queue oriented solutions.