Reputation: 6999
How can I use akka configuration to set default supervision strategy for a router ?
is this valid ?
actor {
deployment {
default {
supervisor-strategy = "akka.actor.DefaultSupervisorStrategy"
}
/my-router {
router = balancing-pool
nr-of-instances = 3
}
}
}
Upvotes: 0
Views: 630
Reputation: 350
As @Diego Martinoia say in current version of akka don't seem to be possible to set the supervision strategy by configuration in a router, but you can mix the configuration of the router and define the strategy programmatically, a java example is:
final SupervisorStrategy strategy = new OneForOneStrategy(10, Duration.create(1, TimeUnit.MINUTES),
Collections.<Class<? extends Throwable>>singletonList(Exception.class));
ActorRef router = system.actorOf(ApiAiActor.props(Http.get(system)).withRouter(FromConfig.getInstance()
.withSupervisorStrategy(strategy)),"router");
In config you can have something like:
akka {
actor.deployment {
/router {
router = round-robin-pool
nr-of-instances = 5
}
}
}
Upvotes: 0
Reputation: 4662
After searching a while, I am surprised to say that I don't think it's possible to do that.
If you look at the reference.conf , you realize that there is no such a property, if not for the guardian (/user).
I fear you are going to have to do it programmatically as stated here.
Your configuration is valid, but that property (supervisor-strategy), while accessible from code, would simply be ignored by akka.
I would be happy to be proven wrong by someone on this one.
Upvotes: 1