Tag Archives: human tasks

Using Variables in JBPM5 Human Tasks

I have been playing a bit with processes and human tasks, and I want to show how we can share variables between human tasks in Jbpm5.

Let’s see the following process:

There are three human tasks which may have input/output:

  • Write document: Should produce an output that should contain a document which will be used by the rest of the process.
  • Translate Document: Should take the “Write document” output to show to the user for reference, and produce an output that will contain the translated document.
  • Review Document: Should take the “Write document” output to show to the user for reference, and produce an output that will contain the review of this document.
First, let’s deal with the write document output.
In the .bpmn file, we will add a new item definition, which will define the structure and a name for this structure, and  then declare a variable inside our process:
Ok, now we should define the variable inside the “Write document” task, and bind it with this process property:
Results will be the name of the variable inside the task.
– In dataOutputAssociation we put the value of the Results to the approval.document variable.
Now, let’s use this variable as an input of “Translate Document”. We will use the already filled approval.document variable, and declare it as a parameter for the task.
Please note for the input variable, I used “Content” name variable. If you see the workitem for human tasks in jbpm5, its takes some predefined parameters and sends them to the task server, so the input information should be put in Content input. Edit: after a salaboy commit some time ago, now, the input of the task will be get from the “content” variable. If you want to send many separate variables, you can omit (send it blank) the content variable, and add other variables. If the human task work item handler  does not find anything in content variable, it will send a map with all the task variables as input.
The complete process definition can be found here:
Now, how can I use it from my human task?
To get the input, using the TaskClient and having the TaskSummary is possible:
To send the output:
The full example can be found in my examples github repository:
That’s all for now. Hope it helps.
Thanks for reading!

Posted by on May 6, 2011 in Drools, JBPM


Tags: , ,

Human Tasks in my process

Although we are living in a world where systems have replaced many human tasks, processes usually need humans to complete tasks in order to achieve some goal, so it is interesting to investigate a bit how these human tasks can be integrated into systems.

Imagine a very simple process for document writing process, defined like this:

In this case, we have three human tasks to be performed by three different people (or groups of people):

  • The person who writes the document.
  • The person who translates the document.
  • The person who review the original document.

In order to finish the document writing process, these three tasks must be finished by the correct people.

There is a specification for human tasks, WS-HumanTask, which standardize not also the notation and meanings, but the way to interact with a human task service. I won’t go in details with the spec, you can check the link in reference, but let’s see some concepts behind it:

Task Data

– A task has data that comes with its definition itself, such as name, description, etc.

– A task has runtime data about its execution, such as its state.

– A task has runtime information about the task definition itself. This data should help the person to complete the task. In the document writing example, the tasks “Review Document” and “Translate Document” has as input a document that has to be used to perform the task.

– A task produces output data, that will give some information about what happened in this task, and also can provide information to the system. For example. In the document writing example, the task “Write Document” produces a document to be used in the rest of the process.

User Roles

There are some roles that are important in the life-cycle of a task. Not only the person who actually performs the task is important, as there can be another actors such as the person who initiates the task, the potential and actual owner, the administrator and notification recipients are some of the roles which could be identified in a task.

Task Interface

To interact with tasks, it is good to have some interfaces to coordinate the task executions, giving enough visibility and functionality. Some needed interfaces could be:

  • Task List. An interface where a user can see all the tasks that has assigned, where a summary of the task is displayed.
  • Task details, where the user can check more details information of a task, with task input data, status, and more.
  • Operate the task. It means a way to start, complete, suspend, the task. It mean, make the task go through its state until finish it.

Task States

The task has different states that change when some operation is made to it. For example, in WS-HumanTask spec, the state diagram for a task is defined like this:

That is just an overview, now we can check some examples!


An interface for human task could like this:

Some interface to select a user (or maybe login), and get some profile for UI customization.

Another interface that should be present is the task list for the user.

And finally the task operation interface, to interact with a selected task.

I have made this example, which let us interact with tasks in a UI pages. The example uses smart task project:

Which allows the interaction between the UI and the task repository, abstracting this job from the producer vendor of the task (can be JBPM, Activiti, I will show an example in another post) and also providing a mechanism to define the configuration of how the information will be shown in the page, defining different profiles and customizations. For now, it does not have support to execute tasks, that’s why in my example I use a simple task client to execute them.

The example can be found here:

For now, it has three projects:

  • human-task-server-example. It is a Jbpm 5 human task server which exposes services to interact with services. Run it with mvn exec:java.
  • human-task-client-example. Run it with mvn exec:java. This is a sample client, which has the possibility to:

Start the writing document sample process.

Complete tasks to finish the process

  • human-task-web-ui-example. This is a web application, run it with mvn jetty:run. There we can:

List all tasks of a user

Get details, form and actions of each task

It only shows how to show the UI, so the actions are not executed.

That’s it for now, I will continue working with this projects and put in this blog things that may be interesting. Please let me know any suggestion, correction or just a hello!

Thanks for reading!



1 Comment

Posted by on May 5, 2011 in Drools, JBPM


Tags: , ,