List of usage examples for io.vertx.core.eventbus DeliveryOptions setSendTimeout
public DeliveryOptions setSendTimeout(long timeout)
From source file:com.hubrick.vertx.kafka.consumer.KafkaConsumerVerticle.java
License:Apache License
private void handler(final String message, final Future<Void> futureResult) { final DeliveryOptions options = new DeliveryOptions(); options.setSendTimeout(configuration.getEventBusSendTimeout()); vertx.eventBus().send(vertxAddress, message, (result) -> { if (result.succeeded()) { futureResult.complete();/*ww w. j a v a 2 s . c o m*/ } else { futureResult.fail(result.cause()); } }); }
From source file:net.kuujo.vertigo.instance.impl.ControlledOutputConnection.java
License:Apache License
/** * Sends a message.//from w w w . j av a 2 s . c o m */ protected OutputConnection<T> doSend(Object message, MultiMap headers, Handler<AsyncResult<Void>> ackHandler) { if (!paused) { // Generate a unique ID and monotonically increasing index for the message. String id = UUID.randomUUID().toString(); long index = currentMessage++; /* Commented out tracking of ackHandlers. Presumably these need to be kept around so new handlers can be created if messages are resent. // if (ackHandler != null) { // ackHandlers.put(index, ackHandler); // } */ // Set up the message headers. DeliveryOptions options = new DeliveryOptions(); if (headers == null) { headers = new CaseInsensitiveHeaders(); } headers.add(ACTION_HEADER, MESSAGE_ACTION).add(ID_HEADER, id).add(INDEX_HEADER, String.valueOf(index)) .add(PORT_HEADER, context.target().port()).add(SOURCE_HEADER, context.target().address()) // TODO: header is called source, but takes the address... .add(ID_HEADER, id).add(INDEX_HEADER, String.valueOf(index)); options.setHeaders(headers); if (context.sendTimeout() > 0) { options.setSendTimeout(context.sendTimeout()); } if (log.isDebugEnabled()) { log.debug("{} - Send: Message[name={}, message={}]", this, id, message); } if (ackHandler != null) { eventBus.send(context.target().address(), message, options, r -> { if (r.succeeded()) { ackHandler.handle(Future.<Void>succeededFuture()); } else { ackHandler.handle(Future.<Void>failedFuture(r.cause())); } }); } else { eventBus.send(context.target().address(), message, options); } checkFull(); } return this; }
From source file:net.kuujo.vertigo.reference.impl.InputPortReferenceImpl.java
License:Apache License
private DeliveryOptions getDeliveryOptions(MultiMap headers) { DeliveryOptions deliveryOptions = new DeliveryOptions(); if (headers != null) { deliveryOptions.setHeaders(headers); }/*from ww w . j a va 2 s. com*/ if (timeout > 0) { deliveryOptions.setSendTimeout(timeout); } deliveryOptions.addHeader("port", name); return deliveryOptions; }
From source file:scp.targets.vertx.CommunicationManagerImpl.java
License:Open Source License
@Override public <T extends Serializable> Pair<Status, Requester<T>> createRequester( @NonNull RequesterConfiguration<T> configuration) { final RequestRequester<T> _requester = new RequestRequester<>(configuration, () -> { final Semaphore _sem = new Semaphore(0); final Box<Pair<ResponderInvokerStatus, TimestampedBox<T>>> _ret = new Box<>(); final DeliveryOptions _opt = new DeliveryOptions(); _opt.setSendTimeout(configuration.maximumLatency); CommunicationManagerImpl.this.eventBus.send(configuration.responderIdentifier, new byte[] {}, _opt, new SendHandler<T, Pair<ResponderInvokerStatus, TimestampedBox<T>>>( configuration.maximumLatency, _sem, _ret)); return waitAndBailOnFailure(_sem, _ret); });//w w w . ja va 2 s . c om return new Pair<>(Status.SUCCESS, _requester); }
From source file:scp.targets.vertx.CommunicationManagerImpl.java
License:Open Source License
@Override public <T extends Serializable> Pair<Status, Sender<T>> createSender( @NonNull SenderConfiguration<T> configuration) { final SendRequester<T> _sender = new SendRequester<>(configuration, (data) -> { final Semaphore _sem = new Semaphore(0); final Box<ReceiverInvokerStatus> _ret = new Box<>(); final DeliveryOptions _opt = new DeliveryOptions(); _opt.setSendTimeout(configuration.maximumLatency); CommunicationManagerImpl.this.eventBus.send(configuration.receiverIdentifier, getBytes(data), _opt, new SendHandler<T, ReceiverInvokerStatus>(configuration.maximumLatency, _sem, _ret)); return waitAndBailOnFailure(_sem, _ret); });/* w w w. ja v a 2 s . co m*/ return new Pair<>(Status.SUCCESS, _sender); }
From source file:scp.targets.vertx.CommunicationManagerImpl.java
License:Open Source License
@Override public <T extends Serializable> Pair<Status, Initiator<T>> createInitiator( @NonNull InitiatorConfiguration<T> configuration) { final InitiateRequester<T> _sender = new InitiateRequester<>(configuration, (data) -> { final Semaphore _sem = new Semaphore(0); final Box<ExecutorInvokerStatus> _ret = new Box<>(); final DeliveryOptions _opt = new DeliveryOptions(); _opt.setSendTimeout(configuration.maximumLatency); CommunicationManagerImpl.this.eventBus.send(configuration.executorIdentifier, getBytes(data), _opt, new SendHandler<T, ExecutorInvokerStatus>(configuration.maximumLatency, _sem, _ret)); return waitAndBailOnFailure(_sem, _ret); });/*from w w w.j av a 2s .c o m*/ return new Pair<>(Status.SUCCESS, _sender); }