How it works...
In this recipe, we looked at how to stop children actor in a deterministic way. The pattern relies on having a surrogate actor that creates the children actors instead of the actual actor. In this example, ServicesManager should be the one creating all the different ServiceHandler actors. However, in order to achieve the ordered termination, we create a third intermediate actor named ServiceHandlersCreator. This actor instantiates the children actors. When the ServicesManager actor starts, it tells ServiceHandlersCreator to get him his children. Then, ServiceHandlersCreator does two things: starts watching for ServicesManager in case of an actor termination and sends the children list to ServicesManager. Afterward, ServicesManager ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access