Waiting for an optional process instance to finish

I’m coming into the middle of a Camunda implementation project and am being asked to model something that I can’t quite figure out. To illustrate, I’ll use vastly simplified process models. The following model will always be instantiated. Let’s call it the mandatory process:


The following optional process will occasionally instantiated:

The requirement is that when ever the optional process has been instantiated, the mandatory process can’t proceed until the optional process instance has completed. The following are possible:

  1. The optional process will not be instantiated at all.
  2. The optional process will have started and finished by the time the mandatory process is instantiated.
  3. The optional process will be started but not finished when the mandatory process is instantiated.

I think I need to modify the mandatory process to be something like:


But it doesn’t quite work. If I modify the optional process model to something like:

The message end event will throw an error if the mandatory process instance hasn’t been created yet.

So, that’s about as far as I’ve got. Does anyone have any ideas?

Thanks!

You’ll need to adjust your outer process a bit.

1 Like

All problems in Computer Science can be solved by another layer of indirection” - David Wheeler

The optional and mandatory processes are currently spawned separately using the Camunda rest api for creating a process instance. They probably shouldn’t be, but I don’t have much control over that.

But I do think I came up with a simple solution. If the optional process throws a completion message and the mandatory process instance hasn’t been created yet, I just catch and ignore the exception.