0

Why do a get a DeathWatchNotification when running this console app:

class Program
{
    private static ActorSystem TestSystem; 

    static void Main(string[] args)
    {
        TestSystem = ActorSystem.Create("TestSystem");
        TestSystem.ActorOf<TestActor>("Test");

        Console.WriteLine("Press a key to shutdown actor system");

        Console.ReadKey();
        TestSystem.Shutdown();
        TestSystem.AwaitTermination();

        Console.WriteLine("Press a key to quit");

        Console.ReadKey(); 
    }
}

public class TestActor : ReceiveActor
{
    public TestActor()
    {

    }
    protected override void Unhandled(object message)
    {
        Console.WriteLine("unhandled message");
        //Do something with the message.
    }

}

public class TestMessage
{

}

Obviously I haven't sent any messages and the actor doesn't do anything. It's not a huge deal but I'm concerned I'll miss a real problem if I ignore this message.

Kyle Reed
  • 71
  • 5
  • possible duplicate of ["Dead letters encountered" as soon as actors are placed into router](http://stackoverflow.com/questions/18971088/dead-letters-encountered-as-soon-as-actors-are-placed-into-router) – Simon MᶜKenzie Sep 03 '15 at 22:56
  • I don't understand. This program sends no messages at all. There is no router, there are no child actors of TestActor, etc. – Kyle Reed Sep 04 '15 at 02:25
  • I'm not an expert, but I thought the answers to that question looked useful to you, particularly _"In this case the only way to get rid of this message is to make sure that router and routees do not terminate "at the same time"."_. – Simon MᶜKenzie Sep 04 '15 at 03:31

1 Answers1

0

As I understand, DeathWatchNotification is a special type of message, that actor sends to its watcher(s) when it's getting terminated. For example, consider this piece of code, that I got from the source of Akka.NET-1.0.4 (ActorCell.DeatWatch.cs file):

    private void SendTerminated(bool ifLocal, IActorRef watcher)
    {
        if (((IActorRefScope)watcher).IsLocal == ifLocal && !watcher.Equals(Parent))
        {
            watcher.Tell(new DeathWatchNotification(Self, true, false));
        }
    }
Usein Mambediiev
  • 243
  • 2
  • 11