Delete Process Instance, still the process Instance continues the execution

Hi All,

I have a scenario where I am suppose to delete the processInstance if triggered externally. so when any task is going on let’s say connector call is waiting for the response from other application (which is around 45-60 secs). So when i try to delete it does get deleted but the execution continues untill async task met.

Is there any way to handle this?


1 Like

@hetal_rathod, try cascade=true deletion, it will delete the created async job for that instances too.

Name Description
cascade true, if all process instances, historic process instances and jobs for this deployment should be deleted.

Hi @aravindhrs,

i don’t want to delete all the processinstances for that process-definition. The deletion would happen on a single process instance currently i am using runtimeService.deleteProcessInstance() java API, It does delete the process instance but it executes all the tasks till endEvent or any async task met. I am having a rest call which takes a lot of time to get the response, meanwhile if the user triggers Delete on that, it does get deleted but when the response comes back that time it will execute the whole process.

Is it a bug or the behaviour is expected?

skipCustomListeners if true, only the built-in ExecutionListener s are notified with the ExecutionListener.EVENTNAME_END event.

you can try this api:

RuntimeService().deleteProcessInstanceIfExists(processInstanceId, deleteReason, skipCustomListeners, externallyTerminated, skipIoMappings, skipSubprocesses);

runtimeService().deleteProcessInstanceIfExists(processInstanceId, deleteReason, true, false, true, true);

Would that stop my connector rest call execution? Let me try this one.
I used runtimeService.deleteProcessInstance(processInstanceId, “User Cancel”,true,true,true,false) before.

Hi @aravindhrs,

I tried, it did not work. see find my test model attached, it has a thread sleep task. During the sleep task, try to delete the process instance by starting delete process (pass process instan ce id) test1.bpmn (8.3 KB))

@hetal_rathod this script was totally wrong. This is not the right way to pass process instance id.

Should be like below:


This will try to delete own instance, which will fail.

Process to process deletion is handled in different way. You need to query by businesskey for process instance or if you know the process instance Id of that process instance and then pass that process instance id as the argument for the delete function to do the delete operation.

ProcessInstance processInstance = execution.getProcessEngineServices()

     .deleteProcessInstance(processInstance.getId(), "deleteReason", true);

For Groovy (not-tested):

def processInstance = execution.getProcessEngineServices().getRuntimeService()

        .deleteProcessInstance(, "deleteReason", true);
1 Like

Correct. I don’t want to delete own process Instance. I hope you understood that part. It is not about how i am fetching the processInstanceId, at the end it is to delete the process instance using

deleteProcessInstance(, “deleteReason”, true);

I think you have not understood my question. The question is while deleting the process instance if there are no ASYNC tasks it executes the process further in a synchronous way where as the process instance is deleted. Would you be able to replicate the scenario? Try thread sleep or try connector and hold the rest call in Debug mode.


Any updates ?