简体   繁体   中英

Akka.net ActorSystem.AwaitTermination triggers DeathWatchNotification when no messages are sent

This message is written to the console in the simplest of Akka.net sample applications.

[INFO][11/3/2015 7:21:06 PM][Thread 0008][akka://TestActorSystem/user] Message DeathWatchNotification from akka://TestActorSystem/user to akka://TestActorSystem/user was not delivered. 1 dead letters encountered.

This is the very simple code, where all you do is create an actor, but you NEVER send any messages.

using System;
using Akka.Actor;
namespace AkkaNetTest {
    class Program {
        static void Main(string[] args) {
            ActorSystem testActorSystem = ActorSystem.Create("TestActorSystem");
            Console.WriteLine("Actor system 'TestActorSystem' created");
            IActorRef testActor = testActorSystem.ActorOf<TestActor>("Test");
            Console.WriteLine("Press a key to shutdown the 'TestActorSystem' actor system");
            Console.ReadKey();
            Console.WriteLine("Attempting to shutdown the actor system");
            testActorSystem.Shutdown();
            Console.WriteLine("Waiting for the actor system to terminate.");
            testActorSystem.AwaitTermination();
            Console.WriteLine("Actor system shutdown, press any key to exit");
            Console.ReadKey(); 
        }
    }
    public class TestActor : ReceiveActor { }
}

The environment I am running in is:

  • Windows 10 RTM build 10240
  • Visual Studio 2013 Update 5
  • Akka.Net via NeGet 1.0.4.12
  • Target framework .NET 4.5
  • Install framework .NET 4.5.2
  • Console Application
  • Any CPU

When you run this simple application the above Akka.net output occurs as soon as the ActorSystem.AwaitTermination() call is made.

It occurs in all my Akka.net applications I try to create and I was able to get it to reproduce in this simple application. So if I send messages or I don't send them it always occurs. If you comment out the IActorRef line then you will not get the message since no actors where created.

This doesn't make any sense why this is happening. If any one can help with explaining why this happens and how to prevent it from happening even when there are no messages that were ever sent then I would appreciate it.

you're calling testActorSystem.Shutdown(); - this shuts down the ActorSystem . This kills off all of the actors, including the built-in system ones - so DeathWatchNotification s are fired as part of the shutdown and cleanup process. In this case the message you're seeing the the /user guardian actor shutting itself down, which doesn't get delivered because it's shutting down.

Not a bug and nothing to be worried about, as explained by the docs: http://getakka.net/docs/concepts/message-delivery-reliability#dead-letters-which-are-usually-not-worrisome

To prevent this error you have to do the following until they fix their default logging level to be WARNING where it should be.

Add the following to your app config and the INFO log message will go away. @Aaronontheweb has stated in the bug report states that this message is "nothing to be worried about".

<configuration>
  <configSections>
    <section name="akka"
             type="Akka.Configuration.Hocon.AkkaConfigurationSection, Akka" />
  </configSections>
  <akka>
    <hocon>
      <![CDATA[
          akka {
            loglevel = WARNING
          }
      ]]>
    </hocon>
  </akka>
</configuration>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM