head_thrash
head_thrash

Reputation: 1711

Akka actors: How to select some of them?

Given I have actor-system with multiple actors:

/users/actor1
/users/actor2
/users/actor3
/users/actor4

And, assuming I'm an actor2, and given every actor knows paths' of others, how do I:

  1. Select actor1, actor3, actor4 (e.g. everyone else but me) and send (e.g. tell or ask) message to them?
  2. Select arbitrary actors, such as actor1, actor4, and do the same?

Documentation says that ActorSelection could be use to broadcast messages for possible many actors, but as far as I can see I can only select one actor per one ActorSelection.

So, do I need one instance of ActorSelection per needed actor, or can I somehow do magic and gather many needed actors in one ActorSelection?

Thanks :-D

Upvotes: 1

Views: 833

Answers (1)

Michał Politowski
Michał Politowski

Reputation: 4385

As shown in the documentation, you can use wildcards (eg. "actor?" or "actor*") when creating the selection to choose multiple matching actors. But truly arbitrary sets seem impossible.

Upvotes: 1

Related Questions