p_a_ll_a_b
p_a_ll_a_b

Reputation: 183

Akka Cluster Leader Address

How do I get a reference to the Leader in a Akka cluster so that I can send a message to the leader node ?

in code :

// assume there exists /user/Supervisor actor at the leader node
val leader = { code to get the leader ref }
leader ! SomeMessage

Upvotes: 2

Views: 1029

Answers (1)

johanandren
johanandren

Reputation: 11479

You can get its address from Cluster(system).state.leader or listen for the LeaderChanged cluster domain event to get notified when it changes.

Upvotes: 5

Related Questions