Prevent process to terminate if an event subprocess is still active

Hi there,

I have a workflow which looks very similar to the first example in the event subprocess documentation page for meal preparation.

I have a subprocess containing both a main flow (‘choose recipe’ and ‘prepare meal’) and an event subprocess that can be called n times just like the “include guest” one in the example.

My issue right now is to be able to prevent the termination of the ‘prepare meal’ task as long as i have an ‘include guest’ subprocess active (ie I have an unfinished ‘take new guest into account’ task).

Is there a way to do this ? I thought of adding a gateway after the ‘prepare meal’ task that could check if an event subprocess exists in which case it would loop back to the ‘prepare meal’ task but I have no clue as to how to write this condition.

Any help would be much appreciated.

Thanks in advance,

Laurent.

Hi @C0chett0,

one solution would be to escalate the failed meal first and wait for finished meal preparation with a conditional event. After this you can delegate the termination.

Maybe something like this: https://cawemo.com/share/01b60938-00d0-4493-b09d-4ace0c420130

Hope this helps, Ingo

Hello @Ingo_Richtsmeier, thanks for your time and answer.

Unfortunately I don’t really see how your idea apply to my case. Especially since I don’t have the ‘failed meal’ part in my workflow, only the cooking and add a guest.

Here is something closer to what I have (very simplified outside the subprocess of course) : https://cawemo.com/share/2e3a1037-a47e-4fd9-a8a2-551af17e85dd

And what I try to achieve is to prevent the task ‘cook meal’ to be terminated if a guest has be annouced but not yet taken into account (new guests number being from 0 to n).

Here is how I would imagine it naively : https://cawemo.com/share/95fe7637-0265-420b-b27c-15a7d68c499d
But I don’t have any idea on how to implement the test in the gateway after the cook meal task.

I don’t know if I make sense but I’ll gladly answer any question to help understand.

As you may have guessed I’m a total beginner in BPMN and maybe this use case should be implemented very differently.

Hi, take problem as easy as you can
One solution could be using an exclusive gateway after cook meal task and check whether there is another new guest? if yes, going back to the cook meal task.

Hello @mrdavoodi64 thank you for your answer. As I understand it, your idea seems to match the one I expose in my second flow.
My question would then be how to check for new guests in this gateway ? Is there a way to count active subprocesses from the gateway ?

To anyone interested I ended up created a process variable called activeNewGuestsCount intialized at 0 when I enter the main subprocess. I increment this variable each time a new guest is annouced and decrement it each time I reach the new guest added step.

Then in my gateway I can just check if this variable is 0 before ending the subprocess.

There may be a more elegant way of doing this but in the meantine it works like a charm !

Once again big thanks to @Ingo_Richtsmeier and @mrdavoodi64 for taking time to read me and provide insights, very much appreciated.

1 Like