akka.net - 集群路由器组的 HOCON 格式?

标签 akka.net

我已经设置了一个 Akka.Net 节点作为集群中的种子节点,我称之为前端,另一个节点我称之为后端。在前端节点中,我在代码中配置了一个集群路由器组,这使我可以将消息从前端发送到任何以“后端”角色加入(以循环方式)并且在/user/有一个参与者的节点后端。我拥有的正在运行的代码如下所示:

system.ActorOf(Props.Empty.WithRouter(
    new ClusterRouterGroup(
        new RoundRobinGroup("/user/backend"),
        new ClusterRouterGroupSettings(10, false, "backend", ImmutableHashSet.Create("/user/backend"))
)));

现在我想将此配置移至配置文件 (hocon)。我该怎么做才能只需要以下代码来实例化它?

system.ActorOf(Props.Empty.WithRouter(FromConfig.Instance), "backend");

我的尝试只产生了异常,没有任何线索。

/backend {
  router = round-robin-group
  routees.paths = ["/user/backend"]
  cluster {
    enabled = on
    max-nr-of-instances-per-node = 1
    allow-local-routees = off
    use-role = backend
  }
}

有什么好的提示吗?我在异常中得到的唯一信息是:

Configuration problem while creating [akka://ClusterSystem/user/backend] with router dispatcher [akka.actor.default-dispatcher] and mailbox  and routee dispatcher [akka.actor.default-dispatcher] and mailbox [].

最佳答案

如果没有看到完整的 HOCON 配置,很难说。似乎您只想要一个集群感知组路由器。没有什么明显的东西跳出来,但我会想到以下几点:

  1. 您是否指定了您的种子节点? 前端 也需要自己作为种子节点。它将“加入自身”以启动集群。
  2. 仔细检查您是否拥有 HOCON 中 Akka.Cluster 的所有必要元素,包括指定 akka.clusterakka.remote HOCON 部分。
  3. /backend 的配置是否在正确的 HOCON 部分?需要在 akka.actor.deployment 中。
  4. 您不需要组路由器的 max-nr-of-instances-per-node 标志。这是为了让池路由器限制它们部署到集群中给定节点上的路由数量。

根据我所见,这是一个适用于 frontend 节点的示例配置。但是,如果您可以添加完整的 HOCON,那将会很有帮助。

akka {
    actor {
        provider = "Akka.Cluster.ClusterActorRefProvider, Akka.Cluster"
        deployment {
            /backend {
                router = broadcast-group
                routees.paths = ["/user/backend"]
                cluster {
                  enabled = on
                  allow-local-routees = on
                  use-role = backend
                  }
                }
        }
    }

    remote {
        log-remote-lifecycle-events = DEBUG
        helios.tcp {
          hostname = "127.0.0.1"
          port = 0
        }
    }

    cluster {
      seed-nodes = ["akka.tcp://ActorSystem@127.0.0.1:1234"] # specify your full frontend seed node address here
      roles = ["frontend"]
      auto-down-unreachable-after = 30s
    }
}

关于akka.net - 集群路由器组的 HOCON 格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31009547/

相关文章:

c# - 如何在 Azure 辅助角色中配置远程参与者配置 (AKKA.NET)

azure - AKKA 是否尝试在内存中执行与 Azure 服务总线队列在磁盘上执行的操作相同的操作?

c# - Akka.net/Generics and Database & Entity Framework

f# - 为什么 Akka.Net F# API 定义了 actorOf2 而不是 actorOf3、actorOf4 等?

testing - 如何使用 akka.net testkit 期待一些消息并忽略其他消息?

c# - 通过Docker容器进行Akka.net远程处理:客户端随机无法连接到主机

c# - 使用 TestKit 测试 Akka.NET 的 Context.Parent

akka.net - Akka.Remote - 解除关联后无法向远程参与者发送消息

akka-stream - Akka.Net Streams 和远程处理 (Sink.ActorRefWithAck)

c# - 为什么这个 FSM 只在一次状态转换中成功?