Come back from eventSubprocess to the main process

Hi, How do I come back to the main process after I finish my event subprocess? For the embedded subprocess, we can continue the flow automatically or some boundary event. But events I have could happen in multiple places of the process, I cannot directly declare the embedded subprocess.
Or, is there any way to catch a message any time before a certain message catch event(or between two message catch events)?
Two things that I tried below. For the first, it’s duplicate. It’s hard to achieve “any time”. For the second, I cannot go back to the main process.
test1.bpmn (12.2 KB)
test2.bpmn (6.4 KB)

Hi @singlash,

there is no direct way to come back from an event subprocess to the main process. If you have an interrupting event subprocess, the main process cannot continue by default.

A non-interrupting event subprocess starts a new token that is independent from the main process token. Both tokens will continue to their end events independently. The main process instance is completed when all tokens reached an end event.

Hope this helps, Ingo


Thank you so much for helping!
Is there any way to go out of the main flow when a certain condition is met or a message is received and go back when the extra flow has been done? like an event-based gateway in multiple places, but I want them to branch to do the same task.

Hi @singlash,

It would be great if you can provide an example of your use case.

But it looks like call activity should fulfill your need if place(s) of the condition to be met is known.

Hi, Thanks for suggesting. I’ve put two bpmn approaches above.
For example, I want to listen to message3 only before message2.
For the first approach, it has many duplicates and is hard to limit stage.
For the second approach, I can manually check the stage when sending messages to check if it’s appropriate. But I’m unable to resume the original process after the subprocess is done.
The problem is that I want to wait for a message catch event in a range instead of a single point.

Hi @singlash,

I can see from your first model “test1” that places of waiting events are known so if you have some reusable logic following message3 then you can encapsulate it in a separate process to be called by a call activity.

But that means that I need a gateway whenever it’s possible. If I have more message(stages), there will be a lot of gateways

Hey @singlash,

as soon as message 3 arrives you want the main process to pause?
If the tasks can run in parallel it is possible to use the event subprocess with a non interrupting message start event like it was mentioned already:
test2.bpmn (6.4 KB)

If you need to pause the main flow and decide every-time you received message 3 if you want to go back to the main flow like in your example 1 it is hard to model that from the BPMN standard. And As suggested already you would need to model event-based gateways.

I am not sure if your logic allows it but if possible you could always come back to the same event based gateway:
test1.bpmn (9.9 KB)

Obviously that has some drawbacks too as now the happy path is not that visible anymore. But it would work technically.

If you run the process with Camunda another “hacky”- option could be to look into process instance modification and modify the process instance before ending the event-sub process from example 2. According to the BPMN standard not correct but it could work in your case.

I hope some of this is helpful

Hey Nele, thank you so much for your reply!!!

  1. I want to block the main process until there’s a result in the subprocess. So parallel doesn’t really work.
  2. in your test1.bpmn example, the order of message1 and message2 is corrupt.
  3. for the process instance modification you mentioned, I was checking this doc Process Instance Modification | It allows me to come back to the main process. But how do I know from which activity I left?
    To me, the event subprocess seems to be the best fit. But I’m not able to come back where I left. The reason I want it is because messages are only to be fired once and it will block the process if I come back in the wrong stage.
    Again, really appreciate your time!!!

“3. how do I know from which activity I left?”

One approach would be to save the current activityId every time an activity starts into a variable through an execution listener. The history database is also capturing this, so it could be possible to retrieve/derive it from a processInstanceQuery.

1 Like

What @Bill_Powell suggested makes a lot of sense.
i build a simple example that more or less implements that functionality, it might be useful as a reference.


Thanks for providing such a great sample!!!
I was trying to use messagestart instead of errorstart in event subprocess. But after I came back to the main process, the messagestart event was no longer working while the errorstart event did work back and forth. Do you know the reason for that?

Good question, I’m not sure about that.
Generally speaking when a process runs the modification api on itself it can lead to strange behaviors and this could be one of those. might be worth creating a bug ticket if you think it should be working the way your intending it to.

1 Like