Why does camunda call listeners when process is deleted?


#1

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?


#2

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


#3

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


#4

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.


#5

This is correct.

Which API/interface do you use for deletion?


#6

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

either cockpit or rest


#7

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/


#8

Thanks @thorben. But we use 7.6 in production


#9

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