protected internal virtual IActivityExecution CreateConcurrentExecution(IActivityExecution scopeExecution) { var concurrentChild = scopeExecution.CreateExecution(); scopeExecution.ForceUpdate(); concurrentChild.IsConcurrent = true; concurrentChild.IsScope = false; return(concurrentChild); }
/// <summary> /// we create a separate execution for each compensation handler invocation. /// </summary> public static void ThrowCompensationEvent(IList <EventSubscriptionEntity> eventSubscriptions, IActivityExecution execution, bool async) { // first spawn the compensating executions foreach (var eventSubscription in eventSubscriptions) { // 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). var compensatingExecution = GetCompensatingExecution(eventSubscription); if (compensatingExecution != null) { if (compensatingExecution.Parent != execution) { // move the compensating execution under this execution if this is not the case yet compensatingExecution.Parent = (PvmExecutionImpl)execution; } compensatingExecution.IsEventScope = false; } else { compensatingExecution = (ExecutionEntity)execution.CreateExecution(); eventSubscription.Configuration = compensatingExecution.Id; } compensatingExecution.IsConcurrent = true; } // signal compensation events in REVERSE order of their 'created' timestamp //eventSubscriptions.Sort(new ComparatorAnonymousInnerClass()); eventSubscriptions = eventSubscriptions.OrderBy(m => m.Created).ToList(); foreach (var compensateEventSubscriptionEntity in eventSubscriptions) { compensateEventSubscriptionEntity.EventReceived(null, async); } }