Bindings, Platforms, and Innovation
This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.
Tracking change and innovation in the enterprise software development community

Posted by Boris Lublinsky on May 05, 2008 02:38 PM
Windows workflow is an excellent framework for implementing business processes. One thing that is missing in it is direct support for human activities. Although several approaches to solving this problem appear in Microsoft publication [1, 2], they are not generic enough for general usage. In this article we will define one of the approaches to a completely generic implementation of human activities in WF.
NEW: ANTS Memory Profiler 5 now out!
Give-away eBook – Confessions of an IT Manager
Effective Management of Static Analysis Vulnerabilities and Defects
Free $40 SOA Demystified Book Offer
Ebook: Scaling Agile with C/ALM
The complexities of supporting human interactions present multiple challenges. Some of them are:
These issues have been realized by the industry and resulted in two major specifications aimed to solve these problems [3, 4]. We will try to build our implementation following the spirit, not the letter of the specifications.
Main components of the overall solution are presented at Figure 1.
Figure 1 Solutions components
In the heart of the solution is a work queue manager. This is a centralized service keeping track of all tasks for all of the users of the system. Any workflow (or a service/application containing workflow), which requires a human activity, invokes a custom workflow activity [5], which submits the request to the work queue manager persisting them and allowing other components of the system to work with these requests. By doing this a work queue manager is becoming a decoupling layer between workflow engine and human activity execution, thus providing support for the cases where user is not present in the system during workflow execution. Also by being a centralized service a work queue manager allows to combine all of the tasks for a given user, regardless of the process that they have initiated from. Because different user tasks can require different input information and can produce different outputs, communications between workflow and human activity is XML in and XML out, which allows processing any possible request and response generically. Although usage of XML might seem as a complicating factor for the implementation, an excellent support for XML serialization, implemented in .Net [6] makes mapping between XML and objects a breeze. A work queue viewer is a GUI application allowing a user to see all of the tasks that are ready for his input. This application is generic, displaying only essential elements of a task, including, name, type, priority, creation, etc. Based on this information in the queue a user can decide to work on a particular task. The actual processing of the task is done by a task application, supporting functionality, specific for a given task. A Work Queue maintenance application provides a UI for administrative support of Work Queue manager. It allows viewing and modifying existing human task, viewing their history, etc. Finally a Human activity is a custom activity (see sidebar "Windows Workflow Foundation Component Model") implementing communications with the Task queue manager and presenting a very simple programming model for the human task execution to the workflow developer. From his point of view human interaction becomes no different than an ordinary service invocation.
Windows Workflow Foundation Component Model
As described in [11], Windows Workflow Foundation (WWF) implementation is very different from executable workflow languages (domain languages) dominating today in workflow implementations. In WWF "activities in a process graph are linked to a component that implements the runtime behavior of that activity in a general purpose programming language. Each activity type in a process language corresponds to one implementation component. For example a web service invocation activity, a human task activity or an email activity all correspond to an implementation component."
As a result, it is extremely simple to extend WWF through introduction of new activity types, implementing runtime behaviors, required in a particular case (human task activity in our case). This approach makes it fairly simple to build new or extend existing process languages through implementations of new activities.
The overall interaction of components is presented at sequence diagram (Figure 2)

Figure 2 Sequence Diagram
As we can see from the above the overall solution includes two types of components:
In this article we will describe only generic components of solution.
As we have defined above, a work queue manager is a centralized service. Its functionality is based on the data contracts, presented at Figure 3.
Figure 3 Work Queue Manager Data Contracts
The major components of this data model are:
Figure 4 Task state transition diagram
When task is submitted to the work queue manager, it is in a ready state. Once it is requested by an application for an execution it transitions to a ready state. When an application completes task process, task moves to a completed state, which signals work queue manager to return response to a human activity about task completion. Alternatively if task processing returns cancel or times out, a task returns back to a ready state.In addition to the data types, data model defines Fault data types, presented at Figure 5.

Figure 5 Fault Data types
A work queue manager exposes three groups of services - Workflow services, User services and Maintenance services.
Workflow service section (Figure 6) defines a service, which is used by a human task activity to submit a task for an execution, and an interface which has to be exposed by a workflow service and is used by a work queue manager to signal execution completion. These two services provide integration between human activity, running in a workflow and a work queue manager.

Figure 6 Workflow Services
Submit for execution service, implemented by a work queue manager, receives requests from human activities that can be part of many different workflows. Once the request is received, it is stored in a database for a further processing.
A completeExecution contract, although defined here, is implemented by a workflow. This service is used to signal workflow that an execution of a particular task is completed and a workflow can proceed.
User services (Figure 7) are implemented in support of user's interactions with a work queue manager. WorkWithItems service supports three operations:
Figure 7 User Services
Maintenance services (Figure 8) are implemented in support of work queue manager maintenance application.
Figure 8 Maintenance Services
View tasks method returns a list of existing task using a filter defined by MaintenanceQuery data type. After looking at the tasks, they can be modified and changes can be returned to the work queue manager using Update task method.
Service database design (Figure 9) Contains tables, necessary for persisting all of the information associated with the human task. The main table - Human task table contains all the basic human task information, including task name, ID (assigned by a service), priority and task life cycle events, supplemented by information about who and when have executed these events.
Figure 9 Work Queue Manger Database
Additional tables contain additional task information and include:
In order to optimize data access we have also implemented several stored procedures and a view. Stored procedures are:
AddTaskCallback is a stored procedure for adding callback information and associating it with a given human task (using InsertTaskCallback stored procedure, below). It first checks whether a given callback already exists and if it does, uses existing callback record, otherwise creating a new one in Callback table. It then invokes an InsertTaskCallback stored procedure to create a link.InsertTaskCallback is a stored procedure populating TaskCallback table, thus creating a relationship between a given callback and a human task.AddTaskType is a stored procedure for adding task type information and associating it with a given human task (using InsertTaskTypeTask stored procedure, below). It first checks whether a given task type already exists and if it does, uses existing task type record, otherwise creating a new one in TaskType table. It then invokes an InsertTaskTypeTask stored procedure to create a link.InsertTaskTypeTask is a stored procedure populating TaskTaskType table, thus creating a relationship between a given task type and a human task.AddTaskPotentialOwner is a stored procedure for adding potential owner information and associating it with a given human task (using InsertTaskPotentialUser stored procedure, below). It first checks whether a given potential owner already exists and if it does, uses existing potential owner record, otherwise creating a new one in PotentialUser table. It then invokes an InsertTaskPotentialUser stored procedure to create a link.InsertTaskPotentialUser is a stored procedure populating TaskPotentialUser table, thus creating a relationship between a given potential owner and a human task.Usage of these stored procedures decreases the amount of database access by about a factor of 2 while minimizing the amount of database data by eliminating duplicates.
Database view (Figure 10) simplifies database accesses for reads. All of the task information (including task type) for a given user can be obtained from a single view.
Figure 10 Complete task view
A class diagram for the persistence layer, implementing repository pattern, is presented at Figure 11.
Figure 11 Persistence class Diagram
The overall implementation of the service is fairly straight forward. Once a particular method is invoked it delegates execution to the repository class (Figure 11), which implements all required database access.
A human activity is a custom workflow activity implementing human interaction. This activity hides communications with the work queue manager from a workflow designer and allows treating user interaction similar to an ordinary service invocation.
Implementation of this activity is based on workflow queues [7] providing asynchronous communication between activities and the outside world: activities register to receive messages on a queue and services send messages on queues. A custom activity can use this model both to handle external events as well as to communicate completion of asynchronous activity execution. This allows an activity to execute up to a point, and then wait for stimulus in order to continue execution. The overall interaction of such implementation is presented at Figure 12.
Figure 12 Activity implementation using Workflow Queue
Once started, activity execution will continue for as long as it can. Upon reaching activity point that requires external execution, the activity registers with a workflow queue. Then the workflow instance enters the waiting state and can be passivated (persisted). Once an external execution completes, it enqueues information into the queue. At this point a runtime reactivates a workflow instance, which continues execution.
The actual implementation of human activity consists of two parts - activity itself and a callback service.
A Human activity sends a message to the human task manager to start a new human task processing. If invocation of this service is successful, the activity registers itself to a workflow queue and goes into waiting state. If there are any errors, executing service, an activity throws a workflow fault that can be processed by a workflow.
When a reply is received by a service it enqueues the reply to the activity's work queue. A queue message wakes up an activity, which dequeues reply and finishes its execution.
A callback service implements complete execution contract (Figure 6) and has to be started by a service/application implementing workflow. In order for this service to work correctly, a WorkflowRuntime has to be set on it. This can be done using a public static variable on a executionComplete class.
A human activity needs several parameters for its execution - task type, priority, etc. These parameters are defined as DependencyProperty [8]. DependencyProperty can then be exposed to be set by workflow designer [9], thus allowing setting activity parameters visually with no programming (Figure 13).
Figure 13 Configuring Activity Parameters
A work queue viewer is implemented as a user control (Figure 14), which can be put on any form. This control implements a dataview control and takes a delegate as a parameter. When any cell of a given row is clicked, a delegate is invoked with a task ID and task type. Figure 14 shows a simple delegate that just pops up a message box.
Figure 14 Work Queue Viewer
Despite the push for complete automation of the business processes, human activities still play, and will continue to play an important role in business process implementations. As we have defined in the beginning of the article introduction of user interactions brings a lot of additional concerns, that are not directly related to workflow implementation. Completely decoupled implementation, described in this article, allows for separation of concerns between workflow development and user interaction development. Additionally, centralization of the human tasks support in the human task manager simplifies an aggregation of task management for a given user.
Many thanks to Paul Rovkah and Rob Sheldon for their help in putting this article together.
1 Jeremy Boyd. Integrating Windows Workflow Foundation and Windows Communication Foundation. MSDN January 2007.
2 Windows Workflow Foundation Web Workflow Approvals Starter Kit?. Microsoft Downloads.
3 Web Services Human Task (WS_HumanTask).
4 WS BPEL extensions for People.
5 Matt Milner. Build Custom Activities To Extend The Reach Of Your Workflows MSDN Magazine, December 2006,
6 Dare Obasanjo XML Serialization in the .NET Framework. January 2003,
7 Serge Luca. Using the Windows Workflow Foundation Queuing system.
8 Glenn Block Attached Properties and the Workflow Designer.
9 Dennis Pilarinos. Getting DependencyProperty RegisterAttached properties to appear in the Property Browser redux.
10 B.Lublinsky, Implementing a Service Registry for .NET Web Services. January 2008, InfoQ,
11 Tom Baeyens. Process Component Models: The Next Generation In Workflow? February 2008, InfoQ.
Would you enroll in an India Forex Group i.e http://www.indiaforex.com Groups?
Thank you for this great "real-life" article! We are working on a project involving workflows and lots of human activities, and this article re-enforces what we started to put in place. Is there any plan for publishing the source code?
Hi, thank you for this excellent article. I really enjoyed it. Like julien I would be very interested in the source code as well. Could we have some feedback if a release of the source is possible or if we have to implement it ourself. Tobi
I really enjoyed this article. Like other two commenters I would like to see the code.
Great article... But isn't it strange that Human Powered Services were an afterthought?
Thank you for this article. We have project underway that has a lot of human interaction. Of course looking at source code would be nice.
Really it's a excellent article. It solve my questions about human activities in an workflow. If is possible, I like to see the code too.
It helps me so much in working with human activities. It will be helpful to see the source code for this if possible. Tanx
about this if it is going to be a commercial/open source product. If there is source code available I would like to know from where. Also, I would like to know how far this architecture would lend itself to being used by 'business' users - e.g. the workflow designer is hosted in a custom tool that works on a code-free model. Many thanks, Sharad
Is there any plan for publishing the source code? Thanks.
This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.
This article explores the use of JBoss and jBPM to implement design solutions that effectively address the issue of orchestrating long running activities.
This presentation covers the use of graph databases as an optimal solution for data that is difficult to fit in static tables, rapidly evolving data or data that has a lot of optional attributes.
This session introduces Real Options and shows how it can help in running your project. Real Options is a decision-making process that can be used to manage risk.
This article discusses the use of bindings on services and references (including the instance of non-configured bindings) as the means to implement SCA communications in a Web and SOA environment.
After a short introduction to DSLs, Scott Davis plays with the keyboard showing how to approach the creation of a DSL by typing working snippets of Groovy code that get executed.
IBM Rational and InfoQ present, Scaling Agile with C/ALM, an eBook showing organizations how to become “finely tuned software delivery machines” by enabling team integration and scaling.
Amanda Laucher presents a real life enterprise application written in F#. She shows actual code snippets, explaining design decisions and suggesting how to use some of the F# constructs.
9 comments
Watch Thread Reply