I am trying to get an multi-threaded application to run against a single kSession.
I have made every serviceTask asynchronous but I CANNOT eliminate problems that I think are related to persistence context.
Each Handler lools like this:
executeWorkItem(WorkItem workItem, WorkItemManager manager ) {
WorkHandlerRunner task = new WorkHanderRunner ( kSession, workItem, this)
threadPoolTaskExecutor.execute ( task )
}
WorkHandlerRunner run looks like this
Constructor saves kSesssion, workItem and workItemHandler
run() {
WorkItemManager manager = kSession.getWorkItemManager()
results = runInTransaction ( manager )
manager.completeWorkItem ( workItem.getId(), results)
}
@Transactional
Map<String, Object> runInTransaction ( WorkItemManager manager) {
// the doExecute does the business work and does not call into kbpm code
return handler.doExecuteWorkItem (workItem, manager)
}
When run it sometimes works for a while but eventually falls over with a mixture of exceptions like
- JPAWorkItemManager.internalWorkItem ( JPAWorkItemManager.java 43 ) - NPA
- ProcessInstanceImp.getProcess ( kruntime null )
I am trying to get a better handle on what happens and when but wonder whether at this light level of reporting someone can spot the obvious mistake.
Cheers,
Richard