Differences

This shows you the differences between two versions of the page.

Link to this comparison view

irc:1479423600 [2017/05/27 13:44] (current)
Line 1: Line 1:
 +[09:29:48] *** ChanServ sets mode: +o temporalfox
 +
 +[12:14:46] *** ChanServ sets mode: +o purplefox
 +
 +[13:34:15] <​Luolong>​ Hey
 +
 +[13:34:50] <​Luolong>​ I have a question about asynchrony in Vert.x
 +
 +[13:37:17] <​Luolong>​ I need to make multiple parallel requests to a REST backend (or multiple REST backends), retrieve their responses and then combine them. How should I go about doing thet from within a Handler?
 +
 +[14:25:55] <​Sticky>​ Luolong: look at https://​docs.oracle.com/​javase/​8/​docs/​api/​java/​util/​concurrent/​CompletableFuture.html#​thenCompose-java.util.function.Function-
 +
 +[14:27:10] <​Sticky>​ note that I think the final result may be executed on a different thread, so you may need to call vertx.runOnContext in the final handler
 +
 +[14:27:18] <​Luolong>​ So you are saying I should use plain old Java8 CompletableFutures for doing async processing in Vertx ?
 +
 +[14:27:46] <​Sticky>​ you can use it to compose multiple results
 +
 +[14:28:06] <​Sticky>​ you can also use rx joins, but its more complex
 +
 +[14:28:21] <​Luolong>​ I am not using Rx for now ...
 +
 +[14:28:44] <​Luolong>​ Just to explain my background a little.
 +
 +[14:56:25] *** ChanServ sets mode: +o temporal_
 +
 +[15:53:36] <​temporal_>​ Luolong you can use vert.x CompositeFuture
 +
 +[15:54:00] <​temporal_>​ http://​vertx.io/​docs/​vertx-core/​java/#​_async_coordination