0

If I have an Akka cluster, what is the best way to access a list of members of that cluster?

I can listen for events and manage my own registry on each node in my cluster. I can also use Cluster(system).state but according to the docs this isn't necessarily in-sync with the published events. Is one of these preferred/better?

My use case is this:

我有一个包含各种服务(不同角色)的集群。当我需要特定角色的服务时,我会在集群中的所有节点列表中进行过滤,以获取具有我需要的角色的节点,然后随机选择其中一个进行通信。这就是为什么我想要集群中所有节点的列表。

这是实现此用例的最佳方法吗?

4

1 回答 1

0

如果激活,集群的成员可以通过 JMX 获得。我想您可以编写一小段代码来访问 MBean 服务器并从那里检索信息。

此外,JMX 对象中还有其他信息可能对您有用,例如我们无法访问的节点。

于 2015-06-10T16:44:02.147 回答