net只重启池中的单个路由
本文关键字:单个 路由 重启 net | 更新日期: 2023-09-27 18:03:13
我有一个RoundRobinPool,我想要使用oneforoneststrategy,这样当一个孩子抛出时,只有那个孩子重新启动。我像这样创建路由器:
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
必须将策略传递给池的构造函数,而不是流畅的Props构建器:
var routerStrat = new OneForOneStrategy(-1, TimeSpan.FromSeconds(5), e => Directive.Restart);
var props = Props.Create<ThrowAlwaysActor>()
.WithRouter(new RoundRobinPool(2, resizer, routerStrat, null));