0

此消息在最简单的 Akka.net 示例应用程序中写入控制台。

[INFO][11/3/2015 7:21:06 PM][Thread 0008][akka://TestActorSystem/user] 从 akka://TestActorSystem/user 到 akka://TestActorSystem/user 的消息 DeathWatchNotification 未传递. 遇到 1 个死信。

这是非常简单的代码,您所做的只是创建一个演员,但您从不发送任何消息。

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 { }
}

我运行的环境是:

  • Windows 10 RTM 内部版本 10240
  • 视觉工作室 2013 更新 5
  • Akka.Net 通过 NeGet 1.0.4.12
  • 目标框架 .NET 4.5
  • 安装框架 .NET 4.5.2
  • 控制台应用程序
  • 任何 CPU

当您运行这个简单的应用程序时,上述 Akka.net 输出会在ActorSystem.AwaitTermination()调用后立即出现。

它出现在我尝试创建的所有 Akka.net 应用程序中,并且我能够在这个简单的应用程序中重现它。因此,如果我发送消息或不发送消息,它总是会发生。如果你注释掉IActorRef行,那么您将不会收到消息,因为没有创建任何演员。

这没有任何意义,为什么会发生这种情况。如果有人可以帮助解释为什么会发生这种情况以及如何防止它发生,即使没有发送过任何消息,那么我将不胜感激。

4

2 回答 2

1

你在打电话testActorSystem.Shutdown();- 这会关闭ActorSystem. 这会杀死所有参与者,包括内置系统的参与者 - 所以DeathWatchNotifications 作为关闭和清理过程的一部分被触发。在这种情况下,您看到的消息是 /user 守护者角色正在关闭,因为它正在关闭,所以它不会被传递。

正如文档所解释的那样,这不是错误,也无需担心

于 2015-11-04T23:29:54.937 回答
-2

为防止出现此错误,您必须执行以下操作,直到他们将默认日志记录级别修复为 WARNING 应该在的位置。

将以下内容添加到您的应用程序配置中,INFO 日志消息将消失。@Aaronontheweb 在错误报告中声明此消息“无需担心”。

<configuration>
  <configSections>
    <section name="akka"
             type="Akka.Configuration.Hocon.AkkaConfigurationSection, Akka" />
  </configSections>
  <akka>
    <hocon>
      <![CDATA[
          akka {
            loglevel = WARNING
          }
      ]]>
    </hocon>
  </akka>
</configuration>
于 2015-11-05T17:54:20.933 回答