Compensation and Cancel events triggered from outside

I’m modelling a process with two main steps. The first step (Choose options Task) prepares data for the second (Fill Forms Transaction) step. The process is being executed by embedded engine within Spring Boot app with own UI. When the process is in any place in the 2nd step (Fill Forms) user can cancel the step and go back to the first one (Choose options).
The basic approach was to attach Signal boundary event to the Fill Forms Transaction going back to Choose options Task. The signal was sent from the spring boot app to the main process id and it worked however there was no compensation.
Now I want to have compensation tasks for Save A & Save B tasks and I can’t quite model it.
I’ve tried to add Event subprocess with Start signal and compensation throw event. It works in a way:

  • it runs compensation tasks for completed Save A/ Save B task [GOOD]
  • it ends the whole process without going back to Choose Options [BAD]
  • I can’t send the signal to main process Id. I managed to overcome it by sending signal without an executionId, but I guess this way it could trigger the signal for all processes of this type, so it’s just for testing. [BAD]

Want I want to achieve:
A way to send an event from Spring Boot app to the given process which would run compensation for all completed tasks of the Fill forms transaction and the process goes back to Choose Options task.
The example process it simplified; there can be many more steps within the transactions and the transaction could be canceled any time (if it’s not completed yet) by the user.

I will be very grateful for some hints :slight_smile:

example_cancel.bpmn (15.7 KB)

1 Like


The modeler doesn’t allow you to model a cancellation event inside an event subprocess. So you could try to eliminate the transaction subprocess, and in your event subprocess receive an event, throw the compensation and then throw an escalation.

Regarding the fact that you can’t signal from the main process execution, why don’t you use a message? It is way more decoupled than having to pass the execution to the signal. You could use the business key to correlate that message. For 1-1 communication, message is the way to go. Any reasons why you would need to use a signal?

Here is a little example model:

This guide also might help you figure it out which events to use and how to use them API-wise:

Thanks Lucas. I know the page, I have Real-Life BPMN book (3d edition) and also watched a bunch of Niall Deehan videos. I was pretty sure that the Cancel event is the way to go and I feel it’s most appropriate semnatics wise.

Ok, I’ll test it with the message and the escalation and I’ll get back with the results.

I’ve also seen this thread:

which looked like the solution, it didn’t work or I didn’t get something.

Maybe try to throw a compensation end rather than a compensation intermediate with a none end event.

The message works like a charm and it triggers the event subprocess easily! Thanks!
The escalation event also works as expected, so I can say I have a working solution.
I’ve also tried the cancel boundary event and compensation end event triggered with a message.
Compensation works of course, but the cancel boundary event does not.