List of usage examples for io.vertx.core.eventbus DeliveryOptions addHeader
public DeliveryOptions addHeader(String key, String value)
From source file:cm.study.vertx.database.WikiDatabaseServiceVertxEBProxy.java
License:Apache License
public WikiDatabaseService fetchAllPages(Handler<AsyncResult<JsonArray>> resultHandler) { if (closed) { resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return this; }//ww w . jav a2s . co m JsonObject _json = new JsonObject(); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "fetchAllPages"); _vertx.eventBus().<JsonArray>send(_address, _json, _deliveryOptions, res -> { if (res.failed()) { resultHandler.handle(Future.failedFuture(res.cause())); } else { resultHandler.handle(Future.succeededFuture(res.result().body())); } }); return this; }
From source file:co.runrightfast.vertx.core.eventbus.EventBusUtils.java
License:Apache License
/** * Adds the following headers:/*from w w w. j av a 2 s . co m*/ * * <ul> * <li>{@link MessageHeader#MESSAGE_ID} * <li>{@link MessageHeader#MESSAGE_TIMESTAMP} * </ul> * * @return DeliveryOptions */ static DeliveryOptions deliveryOptions() { final DeliveryOptions options = new DeliveryOptions(); options.addHeader(MESSAGE_ID.header, uuid()); options.addHeader(MESSAGE_TIMESTAMP.header, DateTimeFormatter.ISO_INSTANT.format(Instant.now())); options.addHeader(FROM_JVM.header, JVM_ID); return options; }
From source file:co.runrightfast.vertx.core.eventbus.EventBusUtils.java
License:Apache License
/** * Adds the {@link MessageHeader#REPLY_TO_ADDRESS} header. * * @param deliveryOptions//from w w w. j a va2s.co m * @param replyToAddress * @return DeliveryOptions */ static DeliveryOptions withReplyToAddress(final DeliveryOptions deliveryOptions, final String replyToAddress) { checkArgument(isNotBlank(replyToAddress)); deliveryOptions.addHeader(REPLY_TO_ADDRESS.header, replyToAddress); return deliveryOptions; }
From source file:co.runrightfast.vertx.core.eventbus.EventBusUtils.java
License:Apache License
/** * Adds the {@link MessageHeader#MESSAGE_CORRELATION_ID} header. * * @param deliveryOptions/*from w ww . ja va 2 s .com*/ * @param correlationId * @return DeliveryOptions */ static DeliveryOptions withCorrelationId(final DeliveryOptions deliveryOptions, final String correlationId) { checkArgument(isNotBlank(correlationId)); deliveryOptions.addHeader(MESSAGE_CORRELATION_ID.header, correlationId); return deliveryOptions; }
From source file:co.runrightfast.vertx.core.eventbus.EventBusUtils.java
License:Apache License
/** * Adds the {@link MessageHeader#FROM_ADDRESS} header. * * @param deliveryOptions//from w w w . j ava 2s .c o m * @param fromAddress * @return DeliveryOptions */ static DeliveryOptions withFromAddress(final DeliveryOptions deliveryOptions, final String fromAddress) { checkArgument(isNotBlank(fromAddress)); deliveryOptions.addHeader(FROM_ADDRESS.header, fromAddress); return deliveryOptions; }
From source file:co.runrightfast.vertx.core.eventbus.EventBusUtils.java
License:Apache License
static DeliveryOptions withFailure(@NonNull final DeliveryOptions deliveryOptions, @NonNull final MessageConsumerConfig.Failure failure) { deliveryOptions.addHeader(FAILURE.header, failure.toJson().toString()); return deliveryOptions; }
From source file:co.runrightfast.vertx.core.eventbus.EventBusUtils.java
License:Apache License
static DeliveryOptions withVerticleDeploymentId(@NonNull final DeliveryOptions deliveryOptions, @NonNull final String deploymentId) { deliveryOptions.addHeader(FROM_VERTICLE.header, deploymentId); return deliveryOptions; }
From source file:co.runrightfast.vertx.core.eventbus.ProtobufMessageProducer.java
License:Apache License
public static DeliveryOptions addRunRightFastHeaders(final DeliveryOptions options) { final MultiMap headers = options.getHeaders(); if (headers == null) { options.addHeader(MESSAGE_ID.header, uuid()); options.addHeader(MESSAGE_TIMESTAMP.header, DateTimeFormatter.ISO_INSTANT.format(Instant.now())); return options; }/* w ww . j av a 2s . co m*/ if (!headers.contains(MESSAGE_ID.header)) { headers.add(MESSAGE_ID.header, uuid()); } if (!headers.contains(MESSAGE_TIMESTAMP.header)) { headers.add(MESSAGE_TIMESTAMP.header, DateTimeFormatter.ISO_INSTANT.format(Instant.now())); } return options; }
From source file:com.appdocker.iop.InternetOfPeopleServiceVertxEBProxy.java
License:Apache License
public void hello(String message, Handler<AsyncResult<String>> resultHandler) { if (closed) { resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed"))); return;// w ww. ja va 2s. co m } JsonObject _json = new JsonObject(); _json.put("message", message); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "hello"); _vertx.eventBus().<String>send(_address, _json, _deliveryOptions, res -> { if (res.failed()) { resultHandler.handle(Future.failedFuture(res.cause())); } else { resultHandler.handle(Future.succeededFuture(res.result().body())); } }); }
From source file:com.appdocker.iop.InternetOfPeopleServiceVertxEBProxy.java
License:Apache License
public void close() { if (closed) { throw new IllegalStateException("Proxy is closed"); }/*from ww w. j a v a 2 s . c o m*/ closed = true; JsonObject _json = new JsonObject(); DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions(); _deliveryOptions.addHeader("action", "close"); _vertx.eventBus().send(_address, _json, _deliveryOptions); }