Reputation: 3828
Is it possible to send message to some actor selection only specific type of class?
Here code for getting actor selection by path:
Akka.system.actorSelection("/path")
Upvotes: 0
Views: 279
Reputation: 14404
It is not possible, since actors are defined by their named location and the messages they handle. This is why an ActorSelection
can only be resolved to an ActorRef
(whether by using Identify
or .resolveOne
), never betraying the implementation.
The benefit of this arrangement is that any actor can be replaced with a different implementation, a router, a proxy, etc. to accommodate changing needs of handling the messages. This is also why you send and receive messages, rather than call methods, so that the receiver of a message and any eventual reply message are not even tied to the same actor.
If you wish to have a class based lookup for your actors, the best way is to set up a registry actor yourself, that is notified of actor creation and keeps that information so that you can query it.
Upvotes: 3