I have been trying to implement multi-threading processes with jBPM, as well as time consuming batch tasks. I found the console was executing the processes in one same main thread, at least so appeared to me, so I tried to put the task logic in a Thread instance and started it in the WorkItemHandler. For single thread but time consuming tasks, which I need to wait for the return, I also passed the ProcessInstance as a parameter, so that when the thread finished its job, it could send out a signal togher with a return Object to notify the process to move forward. And while it was running, it would't occupy the main thread for long time.
Local testing seems fine, only the job wouldn't exit after all things done. Then I put all stuf on web, but this time I met several exceptions, saying like: "java.lang.IllegalArgumentException: IOException while storing workItem 1: org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl$1"
and "Could not commit session or rollback"
So I guess I should not pass the instance reference out, otherwise session may not be able to close or something. But is there a way to signal out from the WorkItemHandler or the Thread it starts, so that I can notify the process instance?
I see there are external signals, but it requires reference to ksession. But I didn't find a clue from either the docs or the API about acquire the ksession reference properly. Could you be so kind to help me out here? Or else I'll have to give up, since time consuming tasks running in the same main thread together will surely be a nightmare.
Thanks,
Bruce