Complete all the tokens before move on from Expanded SubProcess element

Hello,

In a drawing like the one in the picture, the expanded subprocess can be triggered more than once thanks to the non-interrupting message boundary event connected to the user task. In the example, while there was 1 active token waiting in the task, 2 separate requests were sent to the expanded subprocess and 2 separate executions was created in the subprocess. As it can be seen from the history view that 1 of the subprocess executions has been completed (note that the token from the completed execution goes to the end of the main process), the other execution with the expanded subprocess is still active.

What I need?: Until all executions entering the expanded subprocess are completed, no token from the expanded subprocess output can go to the end of the main process.

How can this be achieved using only bpmn element types?

Thank you.

You could make the flow leaving the expanded sub process ending in an end event instead of routing the token back to the process.

Hello @DatyEighty

I guess, I don’t quite understand what you mean, can you please draw it on the process model I’ve added?

Thank you.

ExpandedSubProcess_0qu1ngn.bpmn (6.0 KB)

Just look at this example: Building flexibility into BPMN models | Camunda 8 Docs
It’s similar to your model.

Hello,

I have not been able to find any solution regarding this issue yet.

How can I ensure that a single token will be outputted once from the expanded subprocess after all active tokens in the expanded subprocess are completed?

I cannot use Call Activity elements for the case.

Thanks.

You could use an input execution listener to set a variable called subprocessActive = true and and output listener to subprocessActive = false

Then you could put an XOR gateway before the subprocess to check the variable. like this:

Hey @Niall

Thank you for your answer.

Actually, what I need here is not whether a new token from the non-interrupting message boundary event should enter the subprocess or not according to activeness state of the the subprocess. The non-interrupting message boundary event on the user task can be triggered N times and new tokens can be created at least N times within the subprocess. The part we need to focus on should be the exit side of the subprocess, I guess. Because I want to be sure that there are no active tokens belonging to the subprocess scope left at the subprocess exit.

I couldn’t find anything in the default BPMN element properties that I could use for this purpose. It needs additional development.

I’m working on a JavaDelegate that checks whether there is an active token belonging to the subprocess scope in the subprocess end event. I’m checking the variable with the conditional intermediate catch event to see if there is any active token left that I set in JavaDelegate. Conditional events seem very suitable for this need, the token will not be moving until a certain case occurs.

By the way, 1 token input to the subprocess does not always mean 1 token output. For example, with parallel gateways in the subprocess, 1 token input may cause more than 1 token output. That’s why it made the most sense to check if anything active in the subprocess scope at the subprocess exit.

Thanks.

Hello all,

If anyone is wondering the solution for this specific case, putting the entire process into a new expanded sub process will do the trick.

Since the outer expanded subprocess will create its own scope, it will not allow any tokens to go out of the subprocess unless all active tokens within its own scope are completed. Please see that even though the “Inner End” event was triggered once, the “Main Task” and “End” events outside the subprocess were never triggered. When all active tokens in the subprocess are completed, the activities of the main process will run. Just like I wanted!

I guess, I thought about too much in details. :grinning:

Thanks to @Norman_Luering very much for this practical solution!

2 Likes

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