What's the best way to get members of an Akka cluster

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:

I have a cluster of various services (different roles). When I need a service of a particular role I'd filter on the list of all nodes in the cluster to get the nodes having the role I need, then randomly select one of these to communicate with. That's why I want the list of all nodes in the cluster.

Is that the best way to achieve this use case?

1 Answers
  1. Members of the cluster are available through JMX if activated. I guess you can write a small piece of code that will access the MBean Server and retrieve the information from there.

    Also, there is additional information in the JMX object that could be useful for you such us unreachable nodes.

    hveiga2015-06-10 16:44:02
Related Articles
You Might Also Like