[jboss-user] [jBPM] - Re: Commit transaction after each service task?

Richard Evans do-not-reply at jboss.com
Mon Aug 27 07:08:11 EDT 2012

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...

public final void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
    WorkHandlerRunner task = new WorkHandlerRunner(kSession, workItem, this);
    synchronized (threadPoolTaskExecutor) {

In WorkHandlerRunner...
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.
private Map<String, Object> doRun(WorkItemManager manager) throws Exception {
    return handler.doExecuteWorkItem(workItem, manager);

Reply to this message by going to Community

Start a new discussion in jBPM at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120827/9c9b75fa/attachment.html 

More information about the jboss-user mailing list