How do I "ask" an actor that should be provided by its path?
ask(context.actorSelection("../foo"), GetInfoMessage)
…results in an ActorSelection but only ActorRefs can be "asked".
Alternatively, context.actorFor returns an ActorRef, but this function is deprecated according to the documentation.
Since Akka 2.2.1 you can use ActorSelection.resolveOne to get an ActorRef from a selection:
http://doc.akka.io/api/akka/2.2.1/index.html#akka.actor.ActorSelection
Then you can ask the ActorRef as you normally do
Later on that page you will see
To acquire an ActorRef that is bound to the life-cycle of a specific actor you need to send a message, such as the built-in Identify message, to the actor and use the sender reference of a reply from the actor.
So it's a three step process. Use actorSelection, then send Identify, then ask.
This is only for Akka 2.2 though, so in Akka 2.1 or prior you still need to use actorFor.
The rationale is explained in the 2.2 Migration Guide.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With