3 Replies Latest reply: May 11, 2012 7:56 AM by gardellajp RSS

Trouble getting human task from task service

TC ONG Newbie

Hi All,

I have a process that has multiple human tasks in it. I am using Human Task Service. I have problem getting the human task in 2 scenarios.

 

1> Greb human task right after process start.

 

...

knowledgeSession.startProcess(process, processVariables);    // start process

...

BlockingTaskSummaryResponseHandler taskSummaryHandler = new BlockingTaskSummaryResponseHandler();

taskClient.getTasksAssignedAsPotentialOwner(actor, "en-UK", taskSummaryHandler);

int taskSize = taskSummaryHandler.getResults().size();

logger.debug("Found " + taskSize + " task(s) from the Human Task Service.");

...

 

It gives me 0 results.

But if I go the database, the task was created.

 

Then I try Thread.sleep() for a while.

...

knowledgeSession.startProcess(process, processVariables);    // start process

try {

    logger.debug("Wait for 2 sec.");

    Thread.sleep(2000);

} catch (InterruptedException e) {

    e.printStackTrace();

}

...

BlockingTaskSummaryResponseHandler taskSummaryHandler = new BlockingTaskSummaryResponseHandler();

taskClient.getTasksAssignedAsPotentialOwner(actor, "en-UK", taskSummaryHandler);

int taskSize = taskSummaryHandler.getResults().size();

logger.debug("Found " + taskSize + " task(s) from the Human Task Service.");

...

 

and this time I got the result.

Can I say that when I look for the human task, it is not created in the task service yet.

Obviously what I am doing is stupid and there is a better way to implement it.

Can anyone enlighten me a little bit?

 

 

2> Second case is when I try to get the next task after completing one.

...

BlockingTaskOperationResponseHandler taskOperationHandler = new BlockingTaskOperationResponseHandler();

taskClient.complete(task1.getId(), actor, contentData, taskOperationHandler);

taskOperationHandler.waitTillDone(5000);

...

BlockingTaskSummaryResponseHandler taskSummaryHandler = new BlockingTaskSummaryResponseHandler();

taskClient.getTasksAssignedAsPotentialOwner(actor, "en-UK", taskSummaryHandler);

int taskSize = taskSummaryHandler.getResults().size();

logger.debug("Found " + taskSize + " task(s) from the Human Task Service.");

...


 

Again, anyone, someone, i need your great knowledge.. (ToT)