Reputation: 183
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
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