问题
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
回答1:
Yes, once the actor receives PoisonPill
message, it stop taking anymore messages and send stop to child actors.
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
.
来源:https://stackoverflow.com/questions/33685129/akka-poisonpill-wil-it-kill-descendent-of-its-children