我已经设置了一个 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 配置,很难说。似乎您只想要一个集群感知组路由器。没有什么明显的东西跳出来,但我会想到以下几点:
- 您是否指定了您的种子节点?
前端
也需要自己作为种子节点。它将“加入自身”以启动集群。 - 仔细检查您是否拥有 HOCON 中
Akka.Cluster
的所有必要元素,包括指定akka.cluster
和akka.remote
HOCON 部分。 /backend
的配置是否在正确的 HOCON 部分?需要在akka.actor.deployment
中。- 您不需要组路由器的
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/