Akka PoisonPill是否会杀死其子女的后代? [英] Akka PoisonPill wil it kill descendent of its children?

查看:90
本文介绍了Akka PoisonPill是否会杀死其子女的后代?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用毒丸杀死演员(A)的儿童演员(Bx)。每个孩子都有另一个孩子(Cx)及以后。因此,它希望 A-> B1→ C1,C2,C3→ Dx 。如果我仅将PoisonPill发送给演员B就足够了,那么它将杀死下面的后代演员?

I am using poison pill to kill children (Bx) actor of an actor (A). Each children have another children (Cx) and beyond. So it would like A -> B1 -> C1,C2,C3 -> Dx. Is it enough if I just send PoisonPill to actor B, then it will kill descendent actors below?

Thanksa

推荐答案

是的,一旦演员收到 PoisonPill 消息,它将不再接收消息并将停止发送给子演员。

Yes, once the actor receives PoisonPill message, it stop taking anymore messages and send stop to child actors.

从演员生命周期中可以明显看出,父演员会在 preRestart 期间杀死所有子演员,并等待其终止,在父演员停止之前。如果您不想让孩子停下来,请覆盖preRestart 直接调用 postStop

Its clear from actor lifecycle that the parent actor will kill any child actors during preRestart and wait for its termination, before the parent actor is stopped. In you case dont want children to stop, then override preRestart to directly call postStop.

这篇关于Akka PoisonPill是否会杀死其子女的后代?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆