Since we are talking about supervision and monitoring of actors, you should understand the life cycle hooks of an actor. In this recipe, you will learn how to override the life cycle hooks of an actor when it starts, stops, prestarts, and postrestarts.
Overriding the life cycle hooks of an actor
How to do it...
- Create a file called ActorLifeCycle.scala in package com.packt.chapter2.
- Add the following imports to the top of the file:
import akka.actor._
import akka.actor.SupervisorStrategy._
import akka.util.Timeout
import scala.concurrent.Await
import scala.concurrent.duration._
import akka.pattern.ask
- Create the following messages to be sent to the actors:
case object Error
case class StopActor...