Actor supervision
When studying the actor life cycle, we said that top-level user actors are by default restarted when an exception occurs. We now take a closer inspection at how this works. In Akka, every actor acts as a supervisor for its children. When a child fails, it suspends the processing messages, and sends a message to its parent to decide what to do about the failure. The policy that decides what happens to the parent and the child after the child fails is called the supervision strategy. The parent might decide to do the following:
- Restart the actor, indicated with the
Restart
message - Resume the actor without a restart, indicated with the
Resume
message - Permanently stop the actor, indicated with the
Stop
message - Fail itself with the same ...
Get Learning Concurrent Programming in Scala now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.