Camunda 7 Parallel-Gateway Behavior

Hi Community,
I am learning & working on a BPMN workflow, and I encountered a behavior of parallel-gateway which I am not sure is normal or not. Hoping if some-one can clear my doubts.
Doubt 1 :

So, I have 3 serviceTask executed in parallel which all merges to a parallel-gateway. I wanted to run some logic once in the gateway when all 3 parallel-task are executed & arrives at the gateway.
I used execution listeners both as “start” and “end” event type.
Observation :

  1. The “start” event type gave some application exception. Which was expected. No Issue here. This does not get my job done. So I moved to “end” event type.
  2. The “end” event type was executed 3 times and logic running thrice, one for each parallel task before it. What I was expecting was, end event firing only once hence logic running only once.

My understanding was - the gateway waits for all the incoming concurrent executions and once it receives all incoming result, the gateway would then trigger “end” event once (which makes sense). And I would use this event to run my logic.
But the gateway fires end event for each incoming executions, not sure why this has been modelled this way.

Doubt 2 :
The outgoing paths of the parallel gateway are executed concurrently and not parallel in the sense of parallel threads. All records of a process instance are written to the same partition (single stream processor).

Above lines are from the documentation, what I was trying to achieve was to run 3 independent service tasks in parallel so as to decrease the response time and increase the performance. But the documentation states that the parallel tasks are not executed parallelly but it is executed concurrently (which basically would be same as having those 3 task in series), not sure what purpose parallel gateway really has or how would modelling our WF in parallel would help.

Hoping if some-one can clear my understanding.

Thank you in advance.
Avi

Hi @jonathan.lukas @GotnOGuts , hope you all doing well. I was wandering if you can please help me clear my conceptual doubts :slight_smile:

In BPMN, logic should not be run in a gateway. If you want logic to happen once the parallel tasks have completed, then join them with a parallel gateway and run a service task after it.

Concurrently means “at the same time” which is the common understanding of parallel. If you tune your workers down REALLY low (eg. FetchAndLock limit = 1) while having a long running task; and then vary the number of workers, you will see the difference.

1 Worker → Tasks are effectively sequential, order is up to the worker.
2 Workers → 2 Tasks are started at almost the same time, then 3rd get completed after
3 Workers → All 3 tasks are started at almost the same time.
4 Workers → All 3 tasks are started at almost the same time, one worker remains idle

Truly parallel would mean all 3 tasks are started at exactly the same time.
Concurrent means all 3 tasks are available for a worker to pick up and process at almost the same time.

1 Like