Akka OneForOneStrategy不起作用

src*_*091 3 scala fault-tolerance actor akka

我有以下代码:

class A extends Actor with ActorLogging {
  override val supervisorStrategy = OneForOneStrategy(maxNrOfRetries = 2) { 
    case _ => log.info("An actor has been killed"); Restart 
  }

  val b = context.system.actorOf(Props[B], "b")

  def receive = {
    case _ => context.system.scheduler.schedule(5 seconds, 5 seconds, b, true)
  }
}

class B extends Actor with ActorLogging {
  def receive = { case true => self ! Kill }
}
Run Code Online (Sandbox Code Playgroud)

self ! Kill演员的一个实例中,A我没有看到消息"一个演员已被杀死",随后对演员的调用会A生成"死信"消息,因此没有重启.为什么OneForOneStrategy不被叫?

奇怪的是,我可以删除整个OneForOneStrategy覆盖,并且程序行为没有任何变化.

src*_*091 6

val b = context.system.actorOf(Props[B], "b")应该改为val b = context.actorOf(Props[B], "b")让新演员成为一个孩子,而不是一个顶级演员.