Parallel Gateway not working and delegates executes twice

Hello. I saw similar questions on the form but they didn’t help me… :frowning:
Help me solve the problem with a non-working Parallel Gateway and double execution of delegates in a Spring Boot application (I am attaching an archive with the application).

Pre-conditions: you can clone spring boot app here: GitHub - gorodnyuk/camunda-parallel and run process after running application by http://localhost:8080/camunda/start

The situation is as follows:

  1. An empty list is created in the ListInitializer delegate and placed in the camunda variable(“data”).
  2. According to the idea, the following delegates (ListProcessor1, ListProcessor2, ListProcessor3) should be executed in parallel (the execution time is different, so I set a different delay everywhere using TimeUnit.SECONDS.sleep(5)) and put some data in the list variable(“data”) in sync block. As a result, the list should have 3 variables, the resulting list will be printed in the ListPrinter delegate.
  3. I set the After and Before flags (I tried in different combinations) of Asynchronous Continuations in parallel delegates and it does not work as expected. After starting the process, delegates are executes twice, which can be seen in the logs:
    List Processor 1 is STARTED
    List Processor 2 is STARTED
    List Processor 3 is STARTED
    List Processor 1 is ENDED
    List Processor 3 is ENDED
    List Processor 1 is STARTED
    List Processor 1 is ENDED
    List Processor 2 is STARTED
    List Processor 2 is ENDED

The next time delegates start, there is no variable in the camunda, which is why an NPE occurs… I need that if the delegate fails, there is no need to restart it.

What is the mistake, what am I doing wrong?
Thank you!

P.S. If Parallel Gateway has default settings (the After and Before flags in Asynchronous Continuations are disabled), delegates are executed sequentially, this can be seen in the logs. The result is correct. This is true, but not what I want, because each subsequent delegate waits for the previous one to be executed:

List Processor 1 is STARTED
List Processor 1 is ENDED
List Processor 2 is STARTED
List Processor 2 is ENDED
List Processor 3 is STARTED
List Processor 3 is ENDED

P.S.S. I can do a workaround that involves specifying data variables in each delegate, and then collecting them into a list after the Parallel Gateway in another delegate, but this is not what I want.

The delegates might be run twice because of the automatic retry after a job failure. Please look into the logs.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.