Class Recreate.
Наследование: ISystemMessage
        /// <summary>
        ///     Faults the recreate.
        /// </summary>
        /// <param name="m">The m.</param>
        private void FaultRecreate(Recreate m)
        {
            isTerminating = false;
            ActorBase failedActor = _actor;

            object optionalMessage = CurrentMessage;

            if (System.Settings.DebugLifecycle)
                Publish(new Debug(Self.Path.ToString(), failedActor.GetType(), "restarting"));

            try
            {
                failedActor.AroundPreRestart(m.Cause, optionalMessage);
            }
            catch (Exception e)
            {
                HandleNonFatalOrInterruptedException(() =>
                {
                    var ex = new PreRestartException(_self, e, m.Cause, optionalMessage);
                    Publish(new Error(ex, Self.Path.ToString(), failedActor.GetType(), e.Message));
                });
            }

            var freshActor = NewActor();
            _actor = freshActor;
            UseThreadContext(() =>
            {
                Mailbox.Resume();
                freshActor.AroundPostRestart(m.Cause, null);
            });
            if(System.Settings.DebugLifecycle)
                Publish(new Debug(Self.Path.ToString(), freshActor.GetType(), "restarted (" + freshActor + ")"));
        }
Пример #2
0
        /// <summary>
        ///     Faults the recreate.
        /// </summary>
        /// <param name="m">The m.</param>
        private void FaultRecreate(Recreate m)
        {
            isTerminating = false;
            ActorBase failedActor = Actor;

            object optionalMessage = CurrentMessage;

            if (System.Settings.DebugLifecycle)
                Publish(new Debug(Self.Path.ToString(), failedActor.GetType(), "restarting"));

            try
            {
                failedActor.AroundPreRestart(m.Cause, optionalMessage);
            }
            catch (Exception e)
            {
                HandleNonFatalOrInterruptedException(() =>
                {
                    var ex = new PreRestartException(Self, e, m.Cause, optionalMessage);
                    Publish(new Error(ex, Self.Path.ToString(), failedActor.GetType(), e.Message));
                });
            }

            UseThreadContext(() =>
            {
                behaviorStack.Clear(); //clear earlier behaviors

                ActorBase created = Props.NewActor();
                //ActorBase will register itself as the actor of this context

                if (System.Settings.DebugLifecycle)
                    Publish(new Debug(Self.Path.ToString(), created.GetType(), "started (" + created + ")"));
                created.AroundPostRestart(m.Cause, null);
            });
        }