Cluster.state Consistency

If I subscribe to cluster events via cluster.subscribe, receive some cluster events, and then access cluster.state, will the retrieved state reflect the changes indicated by the cluster events I’ve just received? If not, what kind of consistency should I expect between receiving cluster events and accessing cluster.state?

Hi,

Cluster(system).state 

will only get the full membership state, which is not necessarily in sync with the events published when you subscribe and receive events as they happen. If you need the full changes as they occur, use cluster.subscribe as you are doing. The behavior of subscribe also depends on whether or not you use initialStateMode = InitialStateAsEvents. Here is the current doc for subscribing to Cluster Events: https://doc.akka.io/docs/akka/current/cluster-usage.html#subscribe-to-cluster-events

~Helena