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
messageResume the actor without a restart, indicated with the
Resume
messagePermanently stop the actor, indicated with the
Stop
messageFail itself with the same exception, indicated with the
Escalate
message
By default, the user
guardian actor comes with a supervision strategy that restarts the failed children access. User actors stop their children by default. Both supervision strategies can be overridden...