In order to work with Human Tasks/ User Tasks you need to register a WorkItemHandler that knows what to do when a User task is reached in your processes. You can do that with:
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new ServiceTaskHandler());
Of course you also need to start up the Task Service Server.
Is Human Task a reserved word? why shouldn't it start automatically when the workflow reached HumaTask element?
As well, when I want to mention that I complete the task - how do I do it?
I found that there are start and complete for human task . When shall I use them?
Hmm.. you sound confused..
When you model a BPMN2 process with an User Task, the xml generated creates a tag with an attribute containing the "Human Task" id. This id is used to bind a service that will be in charge of handling the life cycle of a human task (with the line of code that I pasted before). The reason why you need to start the TaskServer by hand is because it's an independant service that you can change if you want and provide a different implementations that suits your needs.
You last sentence ("I found that there are start and complete for human task . When shall I use them?") mention the TaskClient that is in charge of interacting with human tasks that are already created by your process in the Task Server. Using the client you can Start a task (meaning that you will start working on the task) and complete a task (meaning that you end the task).
The interaction between these components can be is described in the following image:
Try reading the following chapter of the Drools Flow documentation for more information:
So I understand that HumanTask has to be the id of that human task in the BPMN file? Since I couldn't find this name in Emergency BPMN diagram, while the EmergencyService has
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new CommandBasedWSHumanTaskHandler(ksession));
You can register different types of HumanTaskHandlers. In the emergency application I've used the CommandBasedWSHumanTaskHandler because it gives you some extra features for different environments. You are true, in my application it didn't have the "Human Task" string in my BPMN file, but that's because I was using an old schema where you need it.
Right now you need to register the "Human Task" workitemHandler with one of the TaskHandlers implementation in order to work.
Sorry for the confusion.
If you are using the SNAPSHOT you don't need to worry about it. The exception that you get:
"org.drools.WorkItemHandlerNotFoundException: Could not find work item handler for Human Task"
Can be solved just registering the "Human Task" WorkItem Handler
Did you do something like:
ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new CommandBasedWSHumanTaskHandler(ksession));?
What is the error now?
I changed it to ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new CommandBasedWSHumanTaskHandler(ksession));
and now it works!! thanks !
Great! keep us posted if you have troubles!