0

我正在尝试将负载分配给多个 akka 演员系统。不幸的是,循环组没有将消息转发给远程工作人员。我可以看到演员已激活,但没有完成任何工作。

完整代码在github

我的配置中是否还有其他设置可能会遗漏?

 private void CreateRemoteCrawlerGroup()
        {
            var hostname = "374110044f24";
            var hostname2 = "25b360699a27";

            var remoteAddress2 = Address.Parse($"akka.tcp://DeployTarget@{hostname2}:8090");
            var remoteScope2 = new RemoteScope(remoteAddress2);
            var remoteCrawler1 =
                Context.ActorOf(
            Props.Create(() => new WebCrawlerActor(new AppSettingsConfiguration(), Self))
            .WithRouter(new RoundRobinPool(2)) // new DefaultResizer(1, 2, messagesPerResize: 500)
                             .WithDispatcher("my-dispatcher")
            .WithDeploy(Deploy.None.WithScope(remoteScope2)), "a");

            var remoteAddress = Address.Parse($"akka.tcp://DeployTarget@{hostname}:8090");

            var remoteScope = new RemoteScope(remoteAddress);
            var remoteCrawler2 =
                Context.ActorOf(
            Props.Create(() => new WebCrawlerActor(new AppSettingsConfiguration(), Self))
            .WithRouter(new RoundRobinPool(2)) // new DefaultResizer(1, 2, messagesPerResize: 500)
                             .WithDispatcher("my-dispatcher")
            .WithDeploy(Deploy.None.WithScope(remoteScope)), "remoteCrawler01");

            var workers = new List<string> { remoteCrawler1.Path.ToString(), remoteCrawler2.Path.ToString() };
            var router = Context.ActorOf(Props.Empty.WithRouter(new RoundRobinGroup(workers)), "some-group");
            _actorDictionary.Add("WebCrawlerActor", router);
        }
4

1 回答 1

0

解决方案是切换到 akka 集群并改用集群池

  var remoteEcho2 =
                Context.ActorOf(
                    Props.Create(() => new WebCrawlerActor(new AppSettingsConfiguration(), Self))
                        .WithRouter(new ClusterRouterPool(new RoundRobinPool(5), new ClusterRouterPoolSettings(5, 1, true, "crawler"))), "WebCrawlerActor2a");

            _actorDictionary.Add("WebCrawlerActor", remoteEcho2);
于 2017-05-31T18:55:08.557 回答