3 Replies Latest reply on Jul 2, 2009 5:24 AM by Huisheng Xu

    How can I suspend or resume a ProcessInstance in jBPM4?

    Huisheng Xu Newbie

      Hi All:

      I have a big problem when suspending/resuming a ProcessInstance in jBPM4.
      A few days ago, I saw there are some feature for Suspending/Resume Execution in jBPM4. So I add this feature to the todolist of my project. But when I start work on this part, I find there is no method in api package to support these feature.

      First I think suspend/resume is similar with the end/delete operation in the ExecutionService.java, but there is no such method. So I go to the Execution.java, Fortunately, there are some code for the suspend:

      /** indicates that this execution is temporary suspended with the
      * {@link #suspend()} method. Human tasks of a suspended execution
      * shouldn't show up in people's task list and timers of suspended
      * executions shouldn't fire and the execution is locked. Make sure that comparisons are
      * done with .equals and not with '==' because if executions are
      * loaded from persistent storage, a new string is created instead
      * of the constants. */
      String STATE_SUSPENDED = "suspended";



      /** is this execution suspended ? */
      boolean isSuspended();

      But these are just a constants for the suspended state and a method for obtain the condition of the execution. I see there is some javadoc for {@link #suspend()}, it seems there may be a method named suspend in the Execution.java. But I can find any method like that.

      Finally I can only to use ExecutionImpl.java in pvm to complete the suspend() and resume() operation. I think there is totally wrong.

      /**
      * FIXME: It is wrong to use implement class.
      */
      ((ExecutionImpl) pi).suspend();

      /**
      * FIXME: It is wrong to use implement class.
      */
      ((ExecutionImpl) pi).resume();

      Anyone has better solution for this? Thank you very much.