ActivityExecution scopeExecution = ScopeUtil.findScopeExecutionForScope((ExecutionEntity) execution, cancelBoundaryEvent.getParentActivity());
// end all executions and process instances in the scope of the transaction
scopeExecution.cancelScope("cancel end event fired");
scopeExecution.interruptScope("cancel end event fired");
// the scope execution executes the boundary event
ActivityExecution outgoingExecution = scopeExecution;
outgoingExecution.setActivity(cancelBoundaryEvent);
outgoingExecution.setActive(true);