[2.1] Akka Piping F.Promise

42 views
Skip to first unread message

SS

unread,
Oct 31, 2012, 4:50:53 AM10/31/12
to play-fr...@googlegroups.com
http://doc.akka.io/docs/akka/2.0.2/java/untyped-actors.html#Ask_Send-And-Receive-Future

I want to use this pattern.

I make a WS call in my Actor which returns a F.Promise. Now I want to pipe this promise to another actor.
Patterns.pipe works with Akka future. How can I achieve this pattern using F.Promise?

James Roper

unread,
Oct 31, 2012, 7:37:45 PM10/31/12
to play-fr...@googlegroups.com
You can convert a play promise to an Akka future by doing something like this:

F.Promise playPromise = ...
Promise akkaPromise = Futures.promise(system.dispatcher());
playPromise.onRedeem(new F.Callback() {
  public void invoke(Object o) {
    akkaPromise.complete(o);
  }
}

You'll probably also want to handle failures, not sure how to do that off the top of my head.
Reply all
Reply to author
Forward
0 new messages