Reputation: 903
Is Akka's PoisonPill is propagated to actor's children or children are simply being stopped without processing the rest of messages? Akka documentation isn't clear and there is an answer to similar question here in StackOverflow referring to old code stating that the children are being stopped, but doesn't make sense to me: why an actor is capable of gracefully processing the messages prior to poison pill, but its children are not.
Upvotes: 1
Views: 147
Reputation: 19527
The PoisonPill
is not propagated to the children. In other words, the children are stopped, not "poisoned." Once the parent processes the PoisonPill
, it is stopped, and then its children are stopped. From the documentation:
...stopping a parent Actor will also recursively stop all the child Actors that this parent has created.
A naive approach would be to send a PoisonPill
to the children before sending a PoisonPill
to the parent. However, actor stopping occurs asynchronously, so there is no guarantee that the children will have processed the messages in their respective mailboxes--up to and including the PoisonPill
--before they are stopped due to the parent's stopping.
To have better control over how an actor's children "die," take a look at this pattern mentioned in the documentation.
Upvotes: 1