We are using the Activiti framework to construct decoupled business processes that will handle specific messages.
BPMN has a notation Parallel Gateway
, which allows us to create flows of tasks that go in "parallel". But is there a mechanisms (a Gateway) to start parallel flows but which will kill other ones as soon as one of the parallel flows finishes?
For example:
StartEvent -> ParallelGateway (fork) -> {FlowA, FlowB, FlowC} -> ParallelGateway (join) -> EndEvent
If FlowB
finishes first, the join Gateway must NOT wait for other ones to finish, stop them (so that they won't need to be executed to the end) and proceed to the next flow (in the example it's an EndEvent).
Any ideas how to achieve that?
EDIT
Found this thread but unfortunately this solution doesn't stop other flows.
A parallel gateway splits the sequence flow into two or more parallel flows or synchronizes or merges the parallel flows again. The synchronization waits until all incoming sequence flows have arrived. Only then is the flow continued.
A parallel gateway splits the sequence flow into two or more parallel flows and joins the parallel flows again. The synchronizing gateway waits until all incoming sequence flows have arrived. Only then is the flow continued. When the sequence flow is split by a parallel gateway, each outgoing sequence flow receives a token.
Kim Nena Duggen, in OCEB 2 Certification Guide (Second Edition), 2016 A parallel gateway splits the sequence flow into two or more parallel flows or synchronizes or merges the parallel flows again. The synchronization waits until all incoming sequence flows have arrived.
Definition A parallel gateway splits the sequence flow into two or more parallel flows and joins the parallel flows again. The synchronizing gateway waits until all incoming sequence flows have arrived. Only then is the flow continued.
You might want to try to make use of a cancel end event within an embedded transactional subprocess. I never used that feature personally, though. See:
http://www.activiti.org/userguide/#bpmnCancelEndEvent http://www.activiti.org/userguide/#bpmnBoundaryCancelEvent
What I have in mind is something like:
Outer StartEvent -> Transactional Subprocess Border -> Inner StartEvent -> ParallelGateway (fork) -> {FlowA, FlowB, FlowC} -> XorGateway (join) -> Inner Cancelling EndEvent -> Transactional Subprocess Border with Boundary Cancel Event attached -> Outer EndEvent (with sequence flow coming from Cancel Boundary Event)
The XOR join will cause the first token to arrive at the cancel end event and therefore to cancel the whole transaction. Obviously this is actually a bit of a "misuse" of the construct of "canceling", because the flow will here ALWAYS cancel the transaction, and not just as an "exception to the rule".
(A "terminate end event" instead of the cancelling end event would be a much better fit from a BPMN perspective. Such an end event actually just terminates the subprocess scope the end event is placed inside. In that case the flow could continue without a Boundary Cancel event attached. However, I am unsure whether Activiti at the moment supports this feature, at least I do not find it in the docs...!)
AFAIK by definition parallel gateways actually do not model concurrent execution like for e.g., threads running concurrently. Instead the executions are run in order starting with the first one until it reaches a wait state/end or parallel join. The execution engine then begins the other execution in order and so on. So waiting seems to be inherent part of parallel execution
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With