2 Replies Latest reply on Mar 9, 2015 3:22 AM by javaken

    JBPM5.4 transactions to use the current MDB context user transaction

    javaken

      Hi All!

       

      I'm currently doing a project in Spring 3, Hibernate 4 and JBPM5.4 running in WebSphere 7. I'm starting my process inside a Message Driven Bean and inside this bean I'm sending another JMS to trigger another Message Driven Bean to continue the process by another Message Driven Bean. Before starting the process, I am beginning the MessageDrivenContext user transaction and committing it right after my JBPM process is executed. It goes something like this:

       

      MDBAbstractMessageBean {

      MessageDrivenContext context = null;

       

      UserTransaction ut = context.getUserTransaction();

      ut.begin();

      //start JBPM processing

      processMessage();

      ut.commit();

      }

       

      One session per process instance is the implementation I used. Everything is well when I'm running a simple process that only triggers 3 Message Driven Beans. The issue comes when I'm trying to run multiple Message Driven Beans. I'm getting StaleStateObject exceptions in ProcessInstanceInfo randomly. My assumption is that the transaction used by the JBPM5.4 engine is not in-synced with the Message Driven Bean's user transaction. Since it is a long running process, I'm thinking that a trigger to the next bean has already started (getting the previous process instance info) but JBPM 5.4 transaction has not yet committed the changes. Is this the case? If my assumption is correct, are there any ways on how I can force JBPM5.4 user transactions to use the current Message Driven Bean's user transaction so that all changes are committed by both the application and JBPM5.4 transactions during the ut.commit() method (application triggers the next bean, JBPM5.4 changes are also comitted so the next Message Driven Bean is sure that there will be no locking exceptions inside the JBPM engine when the next Message Driven bean is started).

       

      Thanks in advance for your help!

        • 1. Re: JBPM5.4 transactions to use the current MDB context user transaction
          swiderski.maciej

          You are getting optimistic lock exception which means you are modifying same process instance from different threads at the same time. What is the use case to do such this? Since you're getting optimistic lock exceptions it means transactions are working as expected, jBPM joins MDB transaction but since there are concurrent operations on same instance one of them will fail.

           

          HTH

          • 2. Re: JBPM5.4 transactions to use the current MDB context user transaction
            javaken

            I think that the user transactions used by the application and JBPM are not the same.

             

            For example I have Bean A and Bean B. Inside Bean A I start the process flow and create a JMS message to trigger the next MDB in Bean B. Bean B will only be triggered right after the ut.commit() is executed. So looking at this specific scenario, it's not supposed to be a concurrent transaction. But somehow, I'm getting this optimistic lock exceptions in the ProcessInstanceInfo randomly inside Bean B so i'm thinking that the JBPM transactions are not in-sync with the MDB user transactions.