Round Robin Group在两个不同的主机上无法正常工作

时间:2017-05-31 17:17:07

标签: akka.net akka.net-networking

我试图在多个akka actor系统上分割负载。 不幸的是,循环组没有向远程工作者转发消息。我可以看到演员已被激活,但没有完成任何工作。

完整代码位于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);
        }

1 个答案:

答案 0 :(得分:0)

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

  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);