I'm trying to implement this pattern in play:
class MyController extends Controller {
def getStuff(actorPath: String) = {
implicit request => Async {
val myFutureStuff = system.actorSelection(actorPath) ? FindStuff()
// Handle the result
}
}
}
But apparently you can't "ask" an ActorSelection, only an ActorRef.
So you have to get an ActorRef from the ActorSelection, which means sending an "Identify" message to the ActorSelection and getting the response back. I can't find a simple way to do this from within the controller, though, as the actor has no way of sending the response of "Identify" back to it.
From examples I've seen where people communicate with actors through the controller, they use ActorRef directly. In my application, I don't want to be hanging on to these ActorRefs. Instead, I fire them up and let them go until I need to communicate with them. When that happens, I want to be able to get a handle to them via their path and ask some information of them.
Is there a better way to do what I want while still using an actor back-end/play front-end approach?
Many thanks