cancel
Showing results for 
Search instead for 
Did you mean: 

suspending a process instance using Execution listener.

asshetye
Champ in-the-making
Champ in-the-making
Hi,

I am new to Activiti Forum.

I am working on a project where I am interested in suspending a process instance using Execution Listener. I want to suspend a process instance as soon as the activity ends and then resume the process instance at a different time  . Could it be possible to do so ??? 

I was just wondering if It might be possible if I get the ProcessInstanceId, I couldn't find a way or is it possible to do so.
Any help !!!


Thanks in advance !
3 REPLIES 3

frederikherema1
Star Contributor
Star Contributor
Suspending the process (using the API) from within the same process will cause issues I think. Is it important that the process-instance is actually suspended? Or is it enough that the process is just "waiting" until a certain point in time/timout is reached to continue. If the latter is the case, you can use an intermediate timer event. This will keep your process waiting until the timer fires and continues the process. Check the user guide for details.

If you're really keen on getting the process-instance suspend, you can always try by getting the EngineService form the delegateExecution, using DelegateExecution#getProcessInstanceId() to pass on to the suspendProcessInstance(), with some luck it will work fine.

I used the EngineService to get the ProcessInstanceId and suspend the process Instance with suspendProcessInstance. It does suspend the instance as I see the values in the database for the process instance where suspension_state is set to 2. But it starts acting weird as in even if the state shows suspended it still performs the next activity and ends the process.

trademak
Star Contributor
Star Contributor
The suspend is not meant to be used in an execution listener on the process instance itself. It's meant to be invoked separately and then it works just fine. To have similar behavior you could use a receive task to have the instance in a wait state and resume it when you want to again.

Best regards,