akka.net 仅重启池中的单个路由

akka.net only restart single routee in a pool

我有一个 RoundRobinPool,我希望对其使用 OneForOneStategy,以便在 child 抛出时仅 child 重新启动。我正在这样创建路由器:

var strat = new OneForOneStrategy(1, TimeSpan.FromSeconds(5), e => Directive.Restart);

var props = Props.Create<ThrowAlwaysActor>()
                        .WithRouter(new RoundRobinPool(2))
                        .WithSupervisorStrategy(strat);

var router = system.ActorOf(props, "myrouter");
router.Tell("1");

输出:

akka://loadSystem/user/myrouter/$b PRERESTART <-- pool init
akka://loadSystem/user/myrouter/$a PRERESTART <-- pool init
akka://loadSystem/user/myrouter/$a OnReceive()
[ERROR][8/21/2016 8:21:02 AM][Thread 0004][akka://loadSystem/user/myrouter] The method or operation is not implemented.
akka://loadSystem/user/myrouter/$a PRERESTART <-- the actor that threw is being restarted
akka://loadSystem/user/myrouter/$b PRERESTART <-- this actor should not be restarted

如何配置 RoundRobin 池以仅重启抛出异常的路由并避免重启整个池。

必须将策略传递给池的构造函数而不是流利的 Props 构建器:

var routerStrat = new OneForOneStrategy(-1, TimeSpan.FromSeconds(5), e => Directive.Restart);

var props = Props.Create<ThrowAlwaysActor>()
                        .WithRouter(new RoundRobinPool(2, resizer, routerStrat, null));