Travers Snyman [
https://community.jboss.org/people/tsnyman] created the discussion
"How to automatically claim a human task after process start"
To view the discussion, visit:
https://community.jboss.org/message/779600#779600
--------------------------------------------------------------
We have recently upgraded to JBPM 5.4 and have come up with an interesting situation.
When we start a process, the next node is a human task and we need to claim the task
automatically by the user that created the process. This used to work in version 5.3, but
in version 4 it seems that we try to claim the task before the task server (in our case
Mina task server) has actually created the human task. The code snippet involved is
something like the following
ProcessInstance processInstance = knowledgeSession.startProcess(processName, params);
BlockingTaskSummaryResponseHandler responseHandler = new
BlockingTaskSummaryResponseHandler();
taskClient.getTasksAssignedAsPotentialOwner(userId, "en-uk", responseHandler);
responseHandler.waitTillDone(2000);
List<TaskSummary> tasks = responseHandler.getResults() ;
if (!tasks.isEmpty()) {
TaskSummary taskSummary = tasks.get(0);
Long tasId = taskSummary.getId();
BlockingTaskOperationResponseHandler responseHandler = new
BlockingTaskOperationResponseHandler();
taskClient.claim(taskId, userId, responseHandler);
responseHandler.waitTillDone(2000);
}
If I put in a manual delay just after the process is started, it works correctly, so it
looks like I need some signal from the task server that the task is created before looking
it up and claiming it with
getTasksAssignedAsPotentialOwner but thus far I have been unable to find a way to do
this.
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/779600#779600]
Start a new discussion in jBPM at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]