*/
public static void throwCompensationEvent(List<CompensateEventSubscriptionEntity> eventSubscriptions, ActivityExecution execution, boolean async) {
// first spawn the compensating executions
for (EventSubscriptionEntity eventSubscription : eventSubscriptions) {
ExecutionEntity compensatingExecution = null;
// check whether compensating execution is already created
// (which is the case when compensating an embedded subprocess,
// where the compensating execution is created when leaving the subprocess
// and holds snapshot data).
if(eventSubscription.getConfiguration() !=null) {
compensatingExecution = Context.getCommandContext()
.getExecutionManager()
.findExecutionById(eventSubscription.getConfiguration());
// move the compensating execution under this execution:
compensatingExecution.setParent((PvmExecutionImpl) execution);
compensatingExecution.setEventScope(false);
} else {
compensatingExecution = (ExecutionEntity) execution.createExecution();
eventSubscription.setConfiguration(compensatingExecution.getId());
}
compensatingExecution.setConcurrent(true);
}
// signal compensation events in reverse order of their 'created' timestamp
Collections.sort(eventSubscriptions, new Comparator<EventSubscriptionEntity>() {
public int compare(EventSubscriptionEntity o1, EventSubscriptionEntity o2) {