5 Replies Latest reply on Nov 3, 2012 6:02 PM by Jason J

    Multiple sessions and thread safety using jBPM persistence

    Jason J Newbie

      For every workflow process I am creating a new separate kbase/ksession.   So every flow is bound to a unique session and not shared.

       

      I have enabled JPA persistence and pass in the following env to each new session:

       

      {code}

      env = KnowledgeBaseFactory.newEnvironment();

      env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);

      env.set(EnvironmentName.TRANSACTION_MANAGER, TransactionManagerServices.getTransactionManager());

      session = createNewSession(env)

      session.startProcess(...)

      {code}

       

       

      I am getting Hibernate StaleObjectExceptions and OptimisticLocking errors when I perform multiple operations on the same process definition, but run on different session IDs.

      I am not sure what specific DB operation is causing this, but since each process is in its own KSession - how is this even possible?

       

      What database update could be in contention between 2 threads in this case?

       

      I am using jBPM5.2.

       

      Any ideas???