Reputation: 5019
I'm using cluster and I would like to send a message to all nodes by role (selector
) in the cluster - similar to broadcast
, but response either on first success or all failed. I don't want wait for timeout such as ScatterGatherFirstCompletedGroup
One way come in my mind is to create my own broadcast, but I have to know how many actors I'm waiting for response. In case all of them failed I'll response immediately. Is there way to find the current nodes in a cluster by role?
Or any other suggestion?
Upvotes: 1
Views: 624
Reputation: 359
You can also create a cluster broadcast router and then gets its routes by sending GetRoutees
message to the router. See also https://doc.akka.io/docs/akka/2.3/scala/routing.html#Managagement_Messages
Upvotes: 0
Reputation: 1182
implicit lazy val actorSystem: ActorSystem = ActorSystem("mysystem")
lazy val cluster = Cluster(actorSystem)
cluster.state.members.filter(m => m.hasRole("admin"))
Upvotes: 2