Question

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.

Was it helpful?

Solution

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

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top