AnsweredAssumed Answered

How to terminate process instance when timer is running?

Question asked by maxlich on Jan 9, 2019

Hi all.
I am writing a service to work with an instance of the process. It has methods for creating a process, completing a user task, etc. Now I got to the method of destroying / stopping the process instance.I wrote such the method:

    @Override
    public void terminateProcessInstance(String processInstanceId) throws ActivitiServiceException {
        try {
            runtimeService.deleteProcessInstance(processInstanceId, "deleted by User");
        } catch (ActivitiObjectNotFoundException e) {
            e.printStackTrace();
            final String message = "There is no process instance with id = " + processInstanceId;
            logger.error(message, e);
            throw new ActivitiServiceException(message, e);
        } catch (Exception e) {
            e.printStackTrace();
            final String message = "There was an exception while terminating the process instance with id = " + processInstanceId + ": ";
            logger.error(message, e);
            throw new ActivitiServiceException(message, e);
        }
    }


And it does not work for me if the timer is running. There is an optimistic lock (in the Activiti engine).

 

How do I kill a process if the timer is running?

Outcomes