Example für CompositeFuture.join()

264 views
Skip to first unread message

mathias

unread,
Feb 26, 2018, 11:10:49 AM2/26/18
to vert.x

Is there any better example for CompositeFuture? I can't get the code following code working:
CompositeFuture.join(future1, future2, future3).setHandler(ar -> {
 
if (ar.succeeded()) {
   
// All succeeded
 
} else {
   
// All completed and at least one failed
 
}
});

  • Must the futures be auf type CompletableFuture?
  • In which thread are the futures executed? I want all futures to run in the working pool
  • How to start the excecution of the futures or the composite?

Kocsis Tibor

unread,
Feb 27, 2018, 9:16:50 AM2/27/18
to vert.x
Hi,

these futures are instances of io.vertx.core.Future class. These are the 'placeholders' for the results of async calculations. You can read a lot of in this topic in the the core vertx docs:

http://vertx.io/docs/vertx-core/java/#_async_coordination

Here you can find a working example code for CompositeFuture, too.

Regards,
Tibor

mathias

unread,
Feb 27, 2018, 11:27:12 AM2/27/18
to vert.x
I don't know which example you have in mind but I there is currently no working exaomple for  CompositeFuture.join:

No example in vertx-x3:
https://github.com/vert-x3/vertx-examples/search?utf8=%E2%9C%93&q=CompositeFuture&type=

No example in CoreExamples:
https://github.com/eclipse/vert.x/blob/c79c698d2dc36f26245e4c390c0db755eb1a91fd/src/main/java/examples/CoreExamples.java

No "directly working" example in the documentation as already said.

I hope that someone has a hint for mew where to read on.


Thomas SEGISMONT

unread,
Feb 28, 2018, 5:41:51 AM2/28/18
to ve...@googlegroups.com
2018-02-26 17:10 GMT+01:00 mathias <roleba...@gmail.com>:

Is there any better example for CompositeFuture? I can't get the code following code working:
CompositeFuture.join(future1, future2, future3).setHandler(ar -> {
 
if (ar.succeeded()) {
   
// All succeeded
 
} else {
   
// All completed and at least one failed
 
}
});

  • Must the futures be auf type CompletableFuture?

No. They can (composite future is also a future) but they don't have to.
 
  • In which thread are the futures executed? I want all futures to run in the working pool

They will execute on the verticle context (unless you're mixing with futures created out of the verticle).
What do you mean by "run in the working pool"?
 
  • How to start the excecution of the futures or the composite?

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/vertx.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/f64f69ac-c7b3-4a84-8079-252508dfd51f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Thomas SEGISMONT

unread,
Feb 28, 2018, 6:14:51 AM2/28/18
to ve...@googlegroups.com
2018-02-26 17:10 GMT+01:00 mathias <roleba...@gmail.com>:
Sorry, I pressed the send button by accident.

You don't "start" the execution. You set a handler on the composite future and you will be notified when the result is ready.
Reply all
Reply to author
Forward
0 new messages