Akka router 的 routees 向自己发送 Terminate 消息

Akka router's routees sends Terminate message to itself

我有一个创建路由器的演员。当所有工作完成后,我想停止当前的演员,停止它的路由器和所有路由。

这是我停止层次结构的代码:

  // stopping children
  context.children foreach context.stop
  // stopping current actor
  context.stop(self)

但在日志中我收到这样的消息:

Message [akka.dispatch.sysmsg.Terminate] from ... to ... was not delivered. [5] dead letters encountered.

即routees 向 itslef 发送 Terminate 消息。

我认为问题与我停止演员的代码有关(上图)。

我该如何解决?

当您停止 self 时,children 会自动停止。所以只需使用 context stop self.