I’ve an actor spawning temporary child actors for some jobs, the parent actor is storing per-actor information in a simple Map, when the child reports the job completion (success or failure) I’m cleaning up the map, everything is ok…
When the job is finished, the child actor reports to the parent, and then, kills itself using poisonPill. To ensure that my map will not contain orphans because of child not reporting, I also have a death watch on them…
To me, it sounds like the death watch is a separate service, thus, the message has no reason to respect the message-from-same-actor ordering thing.
Is there any guarantee that a message sent from the child to the parent actor will arrive before the Terminated ?
The last thing an actor does is execute its
postStop()life-cycle hook; it cannot send any messages by itself after that has returned. The system notification of its termination (as seen by the supervisor’s strategy inhandleChildTerminated(...)) and theTerminatedmessage of DeathWatch are dispatched afterwards, i.e. they happen-after the last message send. Thus, if a message gets sent to some other actor A frompostStop()and that actor A is also registered for receiving theTerminatedmessage, then those messages will be received in the right order (same sender, same receiver => ordering).