public virtual void HandleEvent(EventSubscriptionEntity eventSubscription, object payload,
                                        CommandContext commandContext)
        {
            eventSubscription.Delete();

            var configuration = eventSubscription.Configuration;

            EnsureUtil.EnsureNotNull(
                "Compensating execution not set for compensate event subscription with id " + eventSubscription.Id,
                "configuration", configuration);

            ExecutionEntity compensatingExecution = commandContext.ExecutionManager.FindExecutionById(configuration);

            ActivityImpl compensationHandler = eventSubscription.Activity;

            //activate execution
            compensatingExecution.IsActive = true;

            if (compensatingExecution.GetActivity().ActivityBehavior is ICompositeActivityBehavior)
            {
                compensatingExecution.Parent.ActivityInstanceId = compensatingExecution.ActivityInstanceId;
            }

            if (compensationHandler.IsScope && !compensationHandler.CompensationHandler)
            {
                // descend into scope:
                IList <EventSubscriptionEntity> eventsForThisScope = compensatingExecution.CompensateEventSubscriptions;
                CompensationUtil.ThrowCompensationEvent(eventsForThisScope, compensatingExecution, false);
            }
            else
            {
                try
                {
                    if (compensationHandler.SubProcessScope && compensationHandler.TriggeredByEvent)
                    {
                        compensatingExecution.ExecuteActivity(compensationHandler);
                    }
                    else
                    {
                        // since we already have a scope execution, we don't need to create another one
                        // for a simple scoped compensation handler
                        compensatingExecution.SetActivity(compensationHandler);
                        compensatingExecution.PerformOperation(PvmAtomicOperationFields.ActivityStart);
                    }
                }
                //TODO 暂时取消异常拦截
                //catch (Exception e)
                //{
                //    throw new ProcessEngineException("Error while handling compensation event " + eventSubscription, e);
                //}
                finally
                {
                }
            }
        }
示例#2
0
        public override void Execute(IActivityExecution execution)
        {
            var eventSubscriptions = CollectEventSubscriptions(execution);

            if (eventSubscriptions.Count == 0)
            {
                Leave(execution);
            }
            else
            {
                CompensationUtil.ThrowCompensationEvent(eventSubscriptions, execution, false);
            }
        }
示例#3
0
        public override void Execute(IActivityExecution execution)
        {
            EnsureUtil.EnsureNotNull("Could not find cancel boundary event for cancel end event " + execution.Activity,
                                     "cancelBoundaryEvent", cancelBoundaryEvent);

            var compensateEventSubscriptions = CompensationUtil.CollectCompensateEventSubscriptionsForScope(execution);

            if (compensateEventSubscriptions.Count == 0)
            {
                Leave(execution);
            }
            else
            {
                CompensationUtil.ThrowCompensationEvent(compensateEventSubscriptions, execution, false);
            }
        }