I have an Actor
that creates children using a Router
. When one of the children fail. I'm being notified in the startegy about the failure. However the Actor
does not restart by itself.
private static SupervisorStrategy strategy = new OneForOneStrategy(10, Duration.create("1 minute"),
throwable -> {
Directive directive;
if (throwable instanceof SocketTimeoutException) {
directive = SupervisorStrategy.restart();
} else {
directive = SupervisorStrategy.stop();
}
return directive;
});
I also found out from this SO post that if a child of a Router
terminates, the Router
will not automatically spawn a new child. And also, when all of the router's children terminate, the Router
terminates itself as well.
Now the million dollar question - What is the right way to restart a child that was spawned by a Router
?