Human Tasks in jBPM 5
| Article Index |
|---|
| Human Tasks in jBPM 5 |
| Understanding Human Task states |
| Interacting with the Task programmatically |
| Querying the Tasks |
| All Pages |
In this tutorial we will continue our journey through jBPM5 exploring the Human Task which is based on the WS-HumanTask specification
Many end-to-end business processes require human interactions with the process. For example, humans may be needed for approvals, exception management, or performing activities required to advance the business process. jBPM supports a special human task node inside processes for modeling this interaction with human users.
1) A Human task node
2) A Human Task Server (to be precise a task management component)
3) A Human Task Client
Release comparison: In jBPM 3 Task nodes are just a special kind of wait state node that lives in the same JVM as the process. In jBPM 5, you need a Task Server where task are registered and a Task Client which is used to interact with tasks.
It will be more clear with an example. Start a new jBPM project choosing to add a default example which includes Human Tasks management.
In this very simple example, we have two Human Task nodes.
By clicking on its properties we can see that the Tasks are assigned to the user John an Mary
Looking at the code source, we have the minimal requirement to start the process.
As you can see, this example project uses the jBPMHelper class. The jBPMHelper class can be used to getting started quickly with jBPM5. Let’s see in detail what these method provide:
This method starts the H2 in memory database where all process instances will be stored.
This methods is used to set up a local datasource bound in the JNDI namespace jdbc/jbpm-ds
Inside the META-INF/persistence.xml you can find two persistence units named org.jbpm.persistence.jpa and org.jbpm.task which will be used to persist the process data
Finally, this method is used to start a generic Task Service where all Task will be registered.
In real world application you would rather create your own TaskService and adapt it to your process. Here’s a sample code which can be used to start a Task Service:
Testing the process
Ok, now run the application. The process will be started and the first task will be assigned to user “john”. In order to interact with Tasks, switch to the Human Tasks View (Windows | Show view | Others | Drools tasks | Human Tasks View)
Enter user “john” and hit “Refresh”:
The Task has been reserved to user John. In order to proceed, choose “Start” so that the Task will move to “In Progress” state, until the user has completed the Human Task.
When the user has finally completed the Task, choose “Complete”.
At this point, the process execution will move to the next Human Task node which has been assigned to Mary as you can see from the following picture.
Once you complete also this Task the process will reach the end state.
Please note that the life cycle explained above is the normal life cycle. The service also allows a lot of other life cycle methods. (See http://docs.jboss.org/jbpm/v5.2/userguide/ch.Human_Tasks.html#d0e3854) For example the user can also indicate this using a fault response (possibly with fault data associated), in which case the status is changed to "Failed".

