I have a Supervisor Actor that creates child actors like this:
class SupervisorActor extends Actor {
val child = context.actorOf(MyConnectorActor.props(config),"MyConnector")
def receive = {
case Message => child ! "throw"
}
}
class MyConnectorActor extends Actor {
def receive = {
case "throw" => throw new Exception()
}
}
Now in my MyConnectorActor child, I throw an exception voluntarily. How should the SupervisorActor handle this? Do I need to add the supervisor strategy?
override val supervisorStrategy =
OneForOneStrategy(maxNrOfRetries = 30, withinTimeRange = 1.minute) {
case _ =>
println("RESTARTING CHILD FROM SUPERVISOR")
Restart
}
Even after adding this, I cannot see my child actor restarting? Any ideas as to what else needs to be done?