Reputation: 85
ActorSelection selection = context.actorSelection( "/user/ParentActor/*");
selection.tell(msg,null);
Assumming the parent actor context presented here in the example has more than 1 actor.
Does the above tell statement send message to all child actors sequentially or parallely.That is whether the tell statement behave like a broadcastor or internally an iteration is performed to send message to each actor in the selection
Upvotes: 3
Views: 2060
Reputation: 5962
If you're concerned about performance, it might be better to keep track of the actors, or to use an event bus. In an event bus you can have the actors subscribe to a topic and then you broadcast the message through the event bus. http://doc.akka.io/docs/akka/snapshot/java/event-bus.html
You could also use a router to broadcast to all children. http://doc.akka.io/docs/akka/snapshot/scala/routing.html
Upvotes: 1
Reputation: 4662
Looking here (which is the method called by the tell) it seems to use an iterator, so I'd say sequential.
Nonetheless, it's a quite lightweight operation, so you shouldn't worry too much about it.
Upvotes: 1