Cancel/Complete a waiting Receive task on condition

Suppose I have two service tasks, A and B, which are executed in parallel via inclusive gateway.
Task A (Validations) is a service task that performs some actions, invoking external services for validation.
Task B (Await) is a Receive task which is waiting for a message, that may be sent from external service (kafka topic).
Now, if validations performed by task A fail, there is no point anymore to wait for the message. Is it possible to cancel the Receive task on such condition?
I tried to use boundary Conditional Events but they do not work the way I want - event is triggered and the process goes on, but there’s still a token left in the Receive task waiting for a message.
Here’s a diagram snippet:
(And the reason for such a setup, i.e. parallel execution of these tasks, is because task A may also fail in a retryable fashion, in which case it is retried until success. During this time the message may arrive, so the process needs to be ready to accept it).

Hi @Alek
The problem is that you’ve only appear to have modeled the path where the conditional event is triggered. You need to explicitly model both possible actions.

1 Like