TaskListener for delete event not fired when expected

I have a simple Camunda process with a paralell gateway as shown below:

When I complete for example task1, I expect a delete event to be fired for task2 directly as the execution flow for task2 is deleted (exclusive gateway).

But what happen is that the delete event is only fired when the process is completed, i.e. after I have sent the ‘wait-for-message’ message.

This does not work as expected.

Can somebody tell me if it is a bug, or if it is the expected behavior. If it is expected, is there any documentation explaining this?

Update:

It seems that the task is still marked as active by the taskService of Camunda, which I don’t understand as it is clearly not part anymore of the flow.

Using this query I can still find task2:

taskService.createTaskQuery()
            .active()
            .list();

Hi @ghilainm,

From the BPMN 2.0 Spec:

The Exclusive Gateway has pass-through semantics for a set of incoming branches (merging behavior).

Meaning that the Exclusive Gateway will not terminate any sequence flows. You’ll need to restructure your Process to cancel the Task.

Kind Regards
Martin

Thanks a lot for your answer, was not obvious for me :).