Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Activiti - A Gateway to stop all parallel flows?

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.

like image 351
Serj Lotutovici Avatar asked Feb 10 '14 13:02

Serj Lotutovici


People also ask

How does a parallel gateway work?

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.

How does a parallel gateway synchronize a sequence flow?

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.

What is a parallel gateway in oceb?

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.

What is a parallel gateway in SAP Fico?

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.


2 Answers

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...!)

like image 109
Martin Schimak Avatar answered Sep 26 '22 00:09

Martin Schimak


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

like image 28
Shailendra Avatar answered Sep 23 '22 00:09

Shailendra