February 2018
Intermediate to advanced
552 pages
13h 46m
English
As discussed in the previous lifecycle method, the Actor's Supervisor decides to restart this Actor when it throws any exception. Its Supervisor makes a call to the Actor's postRestart() method immediately so that the Actor enters into the Restarted state.
This postRestart() method, in turn, makes a call to that Actor's preStart() method:
trait Actor{
def preStart(): Unit = ()
def postStop(): Unit = ()
def preRestart(reason: Throwable, message: Option[Any]): Unit = {
context.children foreach { child ⇒
context.unwatch(child)
context.stop(child)
}
postStop()
}
def postRestart(reason: Throwable): Unit = {
preStart()
}
}
Refer to the Akka Actor's lifecycle example section for the full example to understand ...
Read now
Unlock full access