How do I join multiple task executions and execute the next task without waiting for all tasks to finish?

I have this process right now, task 1 and task 2 is executed based on some conditions and they could both be executed or only one of them, task 3 must then be executed after. How can I modify this so that if task 1 and 2 is executed I don’t need to wait for both to finish before executing task 3, either could be finished first and I want task 3 executed immediately.

This might be too much now but I’m also looking for something that would work even if a new task is added in the fork like the image below, but I’m fine with just handling the 2 tasks for now.

Hi @crimson589.
Right now I can think of one possible solution, if it’s still relevant for you.
You could use an exclusive gateway for joining. That would directly pass each token through.
But then you have to take care of the tokens still in the other branches. Because otherwise you would execute Task 3 multiple times (which is probably not what you want).
Also this is under the assumption, that you still want Task 2 to be executed, even if you proceed further on in the process.
I don’t like this solution completely, as you could reach the end of your process, but still wait for Task 2 to be executed. Is this really what you want?
Here is the diagram for reference:

3 Likes

This sounds fine, and yes I still want Task 2 to be executed and I’m fine with Task 2 still being executed as long as the execution of Task 3 does not wait for either of the task before.

On your example where and how is “Is first” and “Not first” set?

Easiest way would be to set a process variable. You could either check if it’s set all all or set it prior to some value (e.g. firstRun = true). And then set it to false via an execution listener on task 3.

@crimson589 what you have used in first image is correct, isnt it working? Inclusive gateway is smart gateway it identifies based on input how many conditions have been satisfied in entry gateway and based on that it waits for either both task 1 and 2 to complete if both matched or either of them.

@Abhijeet_Kotkar the intention was to proceed with task 3 even if both conditions were met and so both paths would be taken.
The gateway at the end would then wait for both tokens before continuing. @crimson589 wants the process instance to move on directly after the first of the tasks is finished.

2 Likes

@rohwerj I was only able to try this now and it’s working as expected, thanks. 2 questions though

  1. Why are there 2 exclusive gateway’s after Task 1 and 2? I tried with only 1 and it still worked as expected.
  2. Is there any possibility of a race condition here where Task 3 gets executed 2 times? although I tried it with a simple workflow that does nothing but log some text and it doesn’t seem to happen so I guess that’s good.

@crimson589 The second gateway is there to prevent the task 3 from getting executed multiple times.
If both (or all) of the paths from the inclusive gateway are taken, then you will get multiple executions of task 3.
I’m wondering why you didn’t see that in your simple test.

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