How to enable compensation in a call activity, based on event in parent process

We have a recursive BPMN process. That is, one path through the flow can result in a Call activity to another instance of the process (at arbitrary depth). One of the first steps in the process is to send an email.

While the subprocess is executing, the parent process needs to be able to cancel that subprocess (basically take back control). If that happens, the subprocess needs to send a “this was canceled” email. That feels like compensation.

Our initial model placed an interrupting Message Boundary event on the Call activity. The problem is that when the boundary event message is received, the subprocess is immediately stopped.

We expect there is a good pattern for modeling such use cases, but haven’t been able to find one that seems elegant and natural, through searches on this forum, studying the BPMN docs, or the Real-Live BPMN book.

I’ve included example BPMN models, omitting recursion for clarity.

SubProcessWithCompensation.bpmn (6.3 KB)
CancelSubprocess2.bpmn (8.2 KB)

Hi @DaveM

Just to clarify - You’ve got a Call Activity which calls a process - if some event happens while the process being called is still running - you want to a specific task in the sub process if it has been executed.

I’m wondering does this compensation ever need to happen after the sub process has been completed?

Hi @Niall thanks for the question.

Yes. If the subprocess is still running, and in that subprocess, the specific task has been executed, that task needs to be compensated.

If the subprocess has completed, then that subprocess task should not be compensated.

Does that make sense?

Hi @DaveM

I played around a bit and found this is probably the best way to do it
The parent Process, after it has run looks like this:

and the sub process looks like this:

Seems to work pretty well.
I’ve upload the example.

1 Like

Thanks @Niall, this looks great and makes sense – much appreciated!