我正在尝试为我的所有 Actor 实现某种控制台编写器。
这是我的代码:
class ConsoleWriterActor : ReceiveActor
{
public ConsoleWriterActor()
{
Receive<object>(s =>
{
Console.WriteLine(s.ToString());
}
}
}
问题是,不知何故, Actor 没有收到任何消息。我从控制台得到了这个日志:
[INFO][8/5/2015 7:30:06 AM][Thread 0013 [akka://SPBOActorSystem/user/ConsoleWriterActor] Message StartDbOperator from akka://SPBOActorSystem/user/DbOperatorActor to akka://SPBOActorSystem/user/ConsoleWriterActor was not delivered. 1 dead letters encountered.
什么地方出了错 ?
最佳答案
听起来您已经解决了 DeadLetters
问题。要回答您的原始问题:要接收 ReceiveActor
中的任何消息,请使用 ReceiveAny
( docs ),如下所示:
class ConsoleWriterActor : ReceiveActor
{
public ConsoleWriterActor()
{
ReceiveAny(o => Console.WriteLine("Received object: " + o));
}
}
关于c# - 如何在 Akka.Net Receive Actor 中接收任何类型的消息,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31826104/