Richard Evans [
https://community.jboss.org/people/r3vans] created the discussion
"Re: Commit transaction after each service task?"
To view the discussion, visit:
https://community.jboss.org/message/756144#756144
--------------------------------------------------------------
Hello Rahul. Yes, I did implement this strategy (or something very similar using a thread
pool). I have often run into problems with the persistence context but have found
everything works if I ensure there is no running transaction when I enter jbpm code.
In a common superclass of all handlers...
@Override
public final void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
WorkHandlerRunner task = new WorkHandlerRunner(kSession, workItem, this);
synchronized (threadPoolTaskExecutor) {
threadPoolTaskExecutor.execute(task);
}
}
In WorkHandlerRunner...
@Override
public void run() {
WorkItemManager manager = kSession.getWorkItemManager();
Map<String, Object> result = null;
try {
result = doRun(manager);
} catch (Exception e) {
...
}
manager.completeWorkItem(workItem.getId(), result);
}
// Do my stuff and commit.
@Transactional
private Map<String, Object> doRun(WorkItemManager manager) throws Exception {
return handler.doExecuteWorkItem(workItem, manager);
}
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/756144#756144]
Start a new discussion in jBPM at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]