scala 一旦演员被放入路由器,“遇到死信”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18971088/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"Dead letters encountered" as soon as actors are placed into router
提问by MCP
Here's what I'm finding, and for the life of me I can't navigate to the reason. I'm creating "printer" actors that basically either do nothing, or print a message based on the type of message they receive.
这就是我所发现的,对于我的生活,我无法找到原因。我正在创建“打印机”角色,它们基本上要么什么都不做,要么根据他们收到的消息类型打印一条消息。
class Printer extends Actor {
def receive = {
case m: SomeMessage => println( m.text )
case _ =>
}
}
I'm creating several of these actors:
我正在创建其中几个演员:
val actor4 = system.actorOf(Props[Printer], "t-4")
val actor5 = system.actorOf(Props[Printer], "t-5")
val actor6 = system.actorOf(Props[Printer], "t-6")
and throwing them into a vector:
并将它们放入一个向量中:
val routees2 = Vector[ActorRef](actor4, actor5, actor6)
I'm doing the above so that I can throw them into a router (and they will be under the router's control). When I run the spec up to this point I'm not having any issues. As soon as I place them in a router and run the spec I'm having problems. Here's the router:
我正在执行上述操作,以便我可以将它们放入路由器(并且它们将在路由器的控制之下)。到目前为止,当我运行规范时,我没有任何问题。一旦我将它们放入路由器并运行规范,我就会遇到问题。这是路由器:
val router = system.actorOf(Props[Printer].withRouter(
BroadcastRouter(routees = routees2)), "router-to-transformers")
Now when I run the spec I have all sorts of dead letters...
现在当我运行规范时,我有各种各样的死信......
[INFO] [09/23/2013 17:10:21.468] [spider-akka.actor.default-dispatcher-6] [akka://spider/user/router-to-transformers] Message [akka.dispatch.sysmsg.DeathWatchNotification] from Actor[akka://spider/user/router-to-transformers#-1845250548] to Actor[akka://spider/user/rout
er-to-transformers#-1845250548] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] [09/23/2013 17:10:21.468] [spider-akka.actor.default-dispatcher-6] [akka://spider/user/router-to-transformers] Message [akka.dispatch.sysmsg.DeathWatchNotification] from Actor[akka://spider/user/router-to-transformers#-1845250548] to Actor[akka://spider/user/rout
er-to-transformers#-1845250548] was not delivered. [2] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] [09/23/2013 17:10:21.468] [spider-akka.actor.default-dispatcher-6] [akka://spider/user/router-to-transformers] Message [akka.dispatch.sysmsg.DeathWatchNotification] from Actor[akka://spider/user/router-to-transformers#-1845250548] to Actor[akka://spider/user/rout
er-to-transformers#-1845250548] was not delivered. [3] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
For the life of me I can't figure out what is going on here. I've added a link to a snippet of the test. The numbering, in the snippet, is weird because I've cut a bunch of different attempts that were commented out so as to not clutter the snippet. I'm focused on this dead-letters issue because I feel like when I added a more actors and actually started passing messages around, things weren't getting delivered... http://snipt.org/AhVf0
对于我的生活,我无法弄清楚这里发生了什么。我添加了一个指向测试片段的链接。代码片段中的编号很奇怪,因为我删除了许多不同的尝试,这些尝试已被注释掉,以免使代码片段混乱。我专注于这个死信问题,因为我觉得当我添加更多演员并实际开始传递消息时,事情并没有得到传递...... http://snipt.org/AhVf0
It's worth calling out that these actors are local. I've read something about actorFor being depreciated and I'm wondering if that is being used and is partly what is causing my issues? There are so many moving parts here though and not a lot of stable, COMPREHENSIVE, documentation. Any help would be greatly appreciated.
值得一提的是,这些演员都是本地人。我读过一些关于 actorFor 被贬值的内容,我想知道它是否正在被使用,部分原因是什么导致了我的问题?虽然这里有很多活动部分,但没有很多稳定、全面的文档。任何帮助将不胜感激。
回答by Roland Kuhn
What you are seeing here is that DeathWatchNotifications are not processed, meaning that the actor (the Router) was still watching its children when it terminated. This is not automatically a sign of trouble as documented(but we should make it clearer in the case of this particular message). 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".
你在这里看到的是 DeathWatchNotifications 没有被处理,这意味着演员(路由器)在它终止时仍在监视它的孩子。这不是自动的风吹草动作为记录(但我们应该在这个特殊消息的情况下,使其更清晰)。在这种情况下,摆脱此消息的唯一方法是确保路由器和路由不会“同时”终止。
回答by nitinsh99
I ran into the same problem with my akka project. Here is my question "Dead Letters encountered" error while running AKKA remote actors
我的 akka 项目遇到了同样的问题。这是我在运行 AKKA 远程演员时出现的问题“遇到死信”错误
Generally dead letter encountered occurs when there is no more worker actor to receive the message sent by master. You should make sure your worker actor is alive when your master is sending it a task or message.
通常遇到死信是在没有更多的工人actor接收master发送的消息时发生。当您的主人向它发送任务或消息时,您应该确保您的工作演员还活着。

