In integrating Akka with Play (have to use Java 7), what I want is for a controller action to fire-and-forget a message to an actor. However, I want the actor to send the response of it's work to the client that sent the http request.
I've successfully tried this with use of ask() in my controller... and want to change it to use tell(). It was "easy" as ask returns a Future.
I know that I need to return a Promise.
I "understand" Future in Akka - just not able to stitch a story together on:
- I'm imagining that in the controller, I can compose a message and pass the
Http.Context
-current()
? - I actually want theHttp.Request
,Http.Response
and maybe theHttp.Session
- send this message to a router actor using
tell
- what does the controller return ?? where is my
Promise< Result>
- am I to create a Future that wraps the tell() ? If so, how? - a worker actor does the work (which could mean serializing some JSON object over Http.Response) and sends a reply to the sender -- which who ?? Play Action?? Imagining that it's a Future in the controller, I would then map the Future< ?> to a
Promise< Result>
??
(something about the above list isn't jiving...)
Why struggle with this? I want to follow the advise in using tell() - http://techblog.net-a-porter.com/2013/12/ask-tell-and-per-request-actors/
Any help appreciated.
Thanks, s-