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:

<extensionElements>

<flowable:eventListener class=“parallel.flowable.test.DeleteProcessListener” entityType=“process-instance” events=“PROCESS_CANCELLED”/>

</extensionElements>

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.

Project: GitHub - enchobelezirev/flowable-test

The diagram is here: flowable-test/src/main/resources/diagrams/main-process.bpmn at master · enchobelezirev/flowable-test · GitHub

The test that checks the problem is here: flowable-test/src/main/java/parallel/flowable/test/TestEventlistener.java at master · enchobelezirev/flowable-test · GitHub

Thanks and best regards,
Encho