此消息在最简单的 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
行,那么您将不会收到消息,因为没有创建任何演员。
这没有任何意义,为什么会发生这种情况。如果有人可以帮助解释为什么会发生这种情况以及如何防止它发生,即使没有发送过任何消息,那么我将不胜感激。