Created
July 6, 2011 00:46
-
-
Save brikis98/1066298 to your computer and use it in GitHub Desktop.
Play framework async I/O with continuations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AsyncTest extends Controller | |
{ | |
public static void continuation() | |
{ | |
F.Promise<WS.HttpResponse> remoteCall1 = WS.url("http://www.remote-service.com/data/1").getAsync(); | |
F.Promise<WS.HttpResponse> remoteCall2 = WS.url("http://www.remote-service.com/data/2").getAsync(); | |
F.Promise<WS.HttpResponse> remoteCall3 = WS.url("http://www.remote-service.com/data/3").getAsync(); | |
F.Promise<List<WS.HttpResponse>> promises = F.Promise.waitAll(remoteCall1, remoteCall2, remoteCall3); | |
List<WS.HttpResponse> httpResponses = await(promises); // request gets suspended here | |
render(httpResponses); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See Play framework and async I/O for more information.