AnsweredAssumed Answered

cancel a process outside of the process

Question asked by supreme06 on Nov 2, 2015
Latest reply on Nov 3, 2015 by martin.grofcik
Hello,
I'm running Seam 2 and Activiti 5.18
I need to create and execute a long asynchonous workflow, during the process, the user should be able to cancel the execution of the workflow (from a JSF page, outside scope of the process)
Whenn the process is running, I tried to call the suspendProcessInstanceById and deleteProcessInstance methods of RuntimeService but they have no incidence on the current runing worflow, I mean the processinstance END_DATE is correctly flagged in the db but the process continue.

Here is the code

processEngine = seamConfiguredProcessEngine.getProcessEngine();
RuntimeService runtimeService = processEngine.getRuntimeService();
pack.setStatus("Cancelled");
packageDao.merge(pack);
runtimeService.setVariable(pack.getJbpmProcessId(), "pack", pack);
runtimeService.suspendProcessInstanceById(pack.getJbpmProcessId());
runtimeService.deleteProcessInstance(pack.getJbpmProcessId(), "deleteReason");

As the process continue, I changed the nodes of the workflow to first get the pack object, check the status and execute my code only if the status is not "Cancelled"

I guess the process keep the variable in cache, because the object I load from the context do not contain the status Cancelled I set previously, and even if I reload the entity using the entityManager (I can see the updated value in the db througt phpMyAdmin).

How can I stop a process or change the values of the entities of a running process when i am outside of this async process?

Thank you

Outcomes