Book Image

Learning Concurrent Programming in Scala

By : Aleksandar Prokopec
5 (1)
Book Image

Learning Concurrent Programming in Scala

5 (1)
By: Aleksandar Prokopec

Overview of this book

Table of Contents (18 chapters)
Learning Concurrent Programming in Scala
Credits
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

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 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...