Search code examples
akkaakka-cluster

How to know initial contacts for Akka Cluster Client?


Akka Cluster Client requires a list of initial nodes that it can contact in order to be in touch with the cluster. It seems that one has to provide at least one exact node address and port. In our environment where it's managed by DC/OS, cluster members can have dynamic address and port association. What's the best way to resolve this? Is there something like Akka Cluster Management support for the Cluster Client?


Solution

  • One way you can achieve that is to use a separate instance of Zookeeper on you DC/OS and use that as a single source of truth for your akka cluster nodes. To manage that you can use a library called akka-zk-cluster-seed from here

    Example config for your cluster client would be smth like this:

    akka.cluster.client {
    zookeeper {
      url = ${ZOOKEEPER_ADDR}
      path = "/akka/cluster/seed"
    }
    establishing-get-contacts-interval = 3s
    refresh-contacts-interval = 60s
    heartbeat-interval = 2s
    acceptable-heartbeat-pause = 5s
    buffer-size = 5000
    

    }

    where the only thing you need to know is your zookeeper location.