RuntimeService::deleteProcessInstance does not trigger the specified listeners

Greetings, Flowable experts, :slight_smile:

I have the following scenario:

  1. I start a process instance using the method RuntimeService::startProcessInstance
  2. When the process is started, I am monitoring it(check whether it is completed, running or in error).
  3. So far so good, but I have the requirement to be able to remove already running processes. So, I decided to use the method from RuntimeService::deleteProcessInstance.
  4. When the process is removed I want to collect some data from it(am using the event which is triggered and from it I am taking the process instance id and based on it i am making queries in order to get the data i need from the database) before it is really deleted. Here comes the problem, I do not see the listener to be triggered when I delete the process instance.
    Here is a snippet from the bpmn diagram of the process:


<flowable:eventListener class=ā€œparallel.flowable.test.DeleteProcessListenerā€ entityType=ā€œprocess-instanceā€ events=ā€œPROCESS_CANCELLEDā€/>


I have a log message in the listener which prints message to the console when it is triggered.
Here come the strange thing - when I remove the entityType=ā€œprocess-instanceā€, the event listener is triggered and the log message appears in the console.

Could you share with me why this could happen? Am I doing something wrong here?

I am attaching github project.(ignore that there is a CallActivity element in it - it was used for other examples in the forum). You can run the test using the main method in the TestEventListener class.


The diagram is here:

The test that checks the problem is here:

Thanks and best regards,