I have a question about mechanism of throwing/catching/handling compensation event in bpmn2.
Based on Travel Booking Example
in bpmn2 by example, we have some compensation intermediate throwing events
, compensation boundary events
and a compensation handler
. I've connected throwing and catching compensation events in this figure (with my knowledge about events):
Is it correct? Can a compensation (booking) throws from outside of an ended sub-process (booking), and activates a compensation event sub-process
(handle compensation) inside it? (the green arrow)
My assumption was not true. Based on activiti documentation:
A compensation boundary event has a different activation policy from other boundary events. Other boundary events like for instance the signal boundary event are activated when the activity they are attached to is started. When the activity is left, they are deactivated and the corresponding event subscription is cancelled. The compensation boundary event is different. The compensation boundary event is activated when the activity it is attached to completes successfully. At this point, the corresponding subscription to the compensation events is created. The subscription is removed either when a compensation event is triggered or when the corresponding process instance ends. From this, it follows:
When compensation is triggered, the compensation handler associated with the compensation boundary event is invoked the same number of times the activity it is attached to completed successfully. If a compensation boundary event is attached to an activity with multiple instance characteristics, a compensation event subscription is created for each instance. If a compensation boundary event is attached to an activity which is contained inside a loop, a compensation event subscription is created for each time the activity is executed. If the process instance ends, the subscriptions to compensation events are cancelled.
The compensation event handler in a sub-process is same.
So the target of red and orange arrows in the given figure, should be the compensation tasks: cancel flight
and cancel hotel
.