Why does camunda call listeners when process is deleted?

I faced a strange problem: when I try to delete a process, listeners attached to a current task of this process are called. Why is it done this way? Is there a way to not to call listeners when process is deleted?

Maybe your Listeners listen to TASK DELETE Event which is thrown when TASK is deleted (not completed) and this happens if process is deleted.

I don’t know of such an event (TASK DELETE) at all. We have execution listeners that are bound to end event type.
image

Ah ok i am not 100% sure but i think end event of execution is thrown when process is deleted because it ends.

You could use Tasklistener instead and listen to complete event. This event is noch thrown if process instance is deleted.

This is correct.

Which API/interface do you use for deletion?

seems like it could work, though i’ll have to modify all listeners to implement TaskListener instead of JavaDelegate.

either cockpit or rest

In newer versions, you have the option to skip listener execution on deletion, see the query parameters documented here: https://docs.camunda.org/manual/7.8/reference/rest/process-instance/delete/

Thanks @thorben. But we use 7.6 in production

As the parameter is there in the Java API, you could implement a custom REST endpoint that exposes it. If that is not option for you, then you could follow Markus’ approach or implement the listener in a way that it works in both situations.

Cheers,
Thorben