private void Handle(TaskEnabled message) { RequireActivation(true); TransitionInfo ti = GetTransition(message.FromTaskInstanceId); if (ti == null) { ti = GetTransition(message.CorrelationId); } if (ti == null) { throw new TaskRuntimeException("Child transition not found: " + message.CorrelationId).SetInstanceId(InstanceId); } if (ti.Status == TransitionStatus.Enabling) { log.Info("MT Child transition {0} has been enabled", ti.InstanceId); ti.Status = TransitionStatus.Enabled; if (ti.InstanceId != message.FromTaskInstanceId) { log.Info("Child task instance id changed {0}->{1}", ti.InstanceId, message.FromTaskInstanceId); ti.InstanceId = message.FromTaskInstanceId; } OnTransitionStatusChanged(ti.InstanceId); } else { log.Debug("Ignoring message: {0}", message); } }
/* RG: not here! * public void Handle(EnableTaskTimeout message) { RequireActivation(true); lock (this) { string corrid = message.CorrelationId; if (string.IsNullOrEmpty(corrid)) { log.Info("No correlation id. Ignoring the message"); return; } TransitionInfo ti = GetTransitionInfo(corrid); if (ti == null) throw new TaskRuntimeException("Child transition not found").SetInstanceId(InstanceId); if (ti.Status == TransitionStatus.Enabling) { //TODO: some cleanup, ye Fail(string.Format("Child task enable timed out: {0}", ti.TaskId)); } else { log.Debug("Ignoring message {0}", message); } } } */ #endregion #region IMessageConsumer<TaskEnabled> Members /// <summary> /// Handle child task enabled message /// </summary> /// <param name="message"></param> private void Handle(TaskEnabled message) { RequireActivation(true); if (message.ParentTaskInstanceId != this.InstanceId) throw new Exception("Parent task correlation id is incorrect"); lock (this) { string childId = string.IsNullOrEmpty(message.CorrelationId) ? message.FromTaskInstanceId : message.CorrelationId; TransitionInfo ti = GetTransitionInfo(childId); if (ti == null) throw new TaskRuntimeException(string.Format("Child transition not found: {0}", childId)).SetInstanceId(InstanceId); if (ti.Status == TransitionStatus.Enabling) { ti.Status = TransitionStatus.Enabled; if (ti.InstanceId != message.FromTaskInstanceId) { //TODO: what if we don't get TaskEnabled, but TaskCompleted as the first event? //we need to handle InstanceId change too!! log.Info("New task instance ID changed {0}->{1}", ti.InstanceId, message.FromTaskInstanceId); ti.InstanceId = message.FromTaskInstanceId; } } else { log.Debug("Ignoring message {0}", message); } } }
private void Handle(TaskEnabled message) { RequireActivation(true); TransitionInfo ti = GetTransition(message.FromTaskInstanceId); if (ti == null) ti = GetTransition(message.CorrelationId); if (ti == null) throw new TaskRuntimeException("Child transition not found: " + message.CorrelationId).SetInstanceId(InstanceId); if (ti.Status == TransitionStatus.Enabling) { log.Info("MT Child transition {0} has been enabled", ti.InstanceId); ti.Status = TransitionStatus.Enabled; if (ti.InstanceId != message.FromTaskInstanceId) { log.Info("Child task instance id changed {0}->{1}", ti.InstanceId, message.FromTaskInstanceId); ti.InstanceId = message.FromTaskInstanceId; } OnTransitionStatusChanged(ti.InstanceId); } else { log.Debug("Ignoring message: {0}", message); } }