1 Reply Latest reply on Mar 7, 2006 3:18 PM by Giuliano Caliari

    lockProcessInstance doesn't seem to be working

    Giuliano Caliari Newbie

      Hello community,

      I?m still evaluating jBPM.
      I have been testing the pessimistic lock mechanism but I couldn?t get it to work, maybe I didn?t understand it.
      I created a workflow (start->node1->node2->end1) and save an instance of it in the database. I tried to read, lock and execute the saved instance with 2 clients, and both managed to read, execute and save the instances in the database. The lock didn?t work.
      Here?s the code:
      jbpmSession.beginTransaction();
      processInstance = jbpmSession.getGraphSession().loadProcessInstance(3961);
      jbpmSession.getGraphSession().lockProcessInstance(3961);
      ContextInstance contextInstance = processInstance.getContextInstance();
      Iterator it=jbpmCtxt.entrySet().iterator();
      while(it.hasNext()){
      Map.Entry entry=(Map.Entry)it.next();
      contextInstance.setVariable((String)entry.getKey(), entry.getValue());
      }
      while(!processInstance.hasEnded()){
      processInstance.signal();
      }
      jbpmSession.getGraphSession().saveProcessInstance(processInstance);
      jbpmSession.commitTransaction();

      Both bode1 and node2 have a loop that takes 40 seconds to end. I run client1 and while it is in the loop, I run client2. As I said, both read and write to the database. Am I doing something wrong? I?m using jBPM 3.0.2.

      Thanks
      Giuliano

        • 1. Re: lockProcessInstance doesn't seem to be working
          Giuliano Caliari Newbie

          Ok, here's some more info on my problem:

          I tested the lock with 2 thin clients accessing the same application server running jBPM and the lock didn't work. When I tested 2 thin clients accessing different applications servers, it worked, I couldn't load the process definition in server2 while server1 was still executing. But after server1 finished, server2 executed the process definition normally. I read somewhere in the forums that it should have rollback. What is correct?

          And I still have the problem that if I use 1 AS with jBPM, any 2 clients can run the same process definition, even though it was locked. Is this really the correct behavior?