ExecutionEntity executionEntity = (ExecutionEntity) execution;
ActivityImpl compensationHandlder = executionEntity.getProcessDefinition().findActivity(compensationHandlerId);
PvmScope scopeActivitiy = compensationHandlder.getParent();
ExecutionEntity scopeExecution = ScopeUtil.findScopeExecutionForScope(executionEntity, scopeActivitiy);
CompensateEventSubscriptionEntity compensateEventSubscriptionEntity = CompensateEventSubscriptionEntity.createAndInsert(scopeExecution);
compensateEventSubscriptionEntity.setActivity(compensationHandlder);
}