List of usage examples for io.vertx.core.eventbus ReplyFailure TIMEOUT
ReplyFailure TIMEOUT
To view the source code for io.vertx.core.eventbus ReplyFailure TIMEOUT.
Click Source Link
From source file:net.kuujo.copycat.vertx.VertxEventBusProtocolClient.java
License:Apache License
@Override public CompletableFuture<ByteBuffer> write(ByteBuffer request) { final CompletableFuture<ByteBuffer> future = new CompletableFuture<>(); context.runOnContext(v -> {/*ww w.j a va 2 s.co m*/ DeliveryOptions options = new DeliveryOptions().setSendTimeout(5000); byte[] bytes = new byte[request.remaining()]; request.get(bytes); vertx.eventBus().send(address, bytes, options, (Handler<AsyncResult<Message<byte[]>>>) result -> { if (result.succeeded()) { future.complete(ByteBuffer.wrap(result.result().body())); } else { ReplyException exception = (ReplyException) result.cause(); if (exception.failureType() == ReplyFailure.NO_HANDLERS || exception.failureType() == ReplyFailure.TIMEOUT) { future.completeExceptionally(new ProtocolException(exception)); } else { future.completeExceptionally(new CopycatException(exception.getMessage())); } } }); }); return future; }
From source file:org.jboss.weld.vertx.VertxObservers.java
License:Apache License
public void consumerSendTimeout(@Observes @VertxConsumer(TEST_BUS_TIMEOUT) VertxEvent event) { assertEquals(TEST_BUS_TIMEOUT, event.getAddress()); event.messageTo(TEST_SLOW_HANDLER).setDeliveryOptions(new DeliveryOptions().setSendTimeout(10)).send("foo", (r) -> {/*w w w . j a v a2s.co m*/ if (r.failed()) { ReplyException exception = (ReplyException) r.cause(); if (exception.failureType().equals(ReplyFailure.TIMEOUT)) { SYNCHRONIZER.add("timeout"); } } }); }