本文整理汇总了Java中io.vertx.core.eventbus.DeliveryOptions类的典型用法代码示例。如果您正苦于以下问题:Java DeliveryOptions类的具体用法?Java DeliveryOptions怎么用?Java DeliveryOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DeliveryOptions类属于io.vertx.core.eventbus包,在下文中一共展示了DeliveryOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processOneResult
import io.vertx.core.eventbus.DeliveryOptions; //导入依赖的package包/类
protected void processOneResult(final JsonObject dataChange) {
final JsonObject data = dataChange.getJsonObject("data");
final JsonObject payload = data.getJsonObject("payload");
// We send it off to the eventbus and in any case have the
// final destination header set - just in case
final EventBus eb = this.getVertx().eventBus();
final DeliveryOptions opts = new DeliveryOptions();
this.getListenerConfig().getEventBusAddresses().forEach(destination -> {
opts.addHeader(Constants.BUS_FINAL_DESTINATION, destination);
});
// Intermediate step for deduplication of messages
if (this.useDedupService()) {
eb.publish(this.getListenerConfig().getEventBusDedupAddress(), payload, opts);
} else {
this.getListenerConfig().getEventBusAddresses().forEach(destination -> {
try {
eb.publish(destination, payload, opts);
this.logger.info("Sending to [" + destination + "]:" + payload.toString());
} catch (final Throwable t) {
this.logger.error(t.getMessage(), t);
}
});
}
}
示例2: indexHandler
import io.vertx.core.eventbus.DeliveryOptions; //导入依赖的package包/类
private void indexHandler(RoutingContext context) {
DeliveryOptions options = new DeliveryOptions().addHeader("action", "all-pages"); // <2>
vertx.eventBus().send(wikiDbQueue, new JsonObject(), options, reply -> { // <1>
if (reply.succeeded()) {
JsonObject body = (JsonObject) reply.result().body(); // <3>
context.put("title", "Wiki home");
context.put("pages", body.getJsonArray("pages").getList());
templateEngine.render(context, "templates", "/index.ftl", ar -> {
if (ar.succeeded()) {
context.response().putHeader("Content-Type", "text/html");
context.response().end(ar.result());
} else {
context.fail(ar.cause());
}
});
} else {
context.fail(reply.cause());
}
});
}
示例3: importTx
import io.vertx.core.eventbus.DeliveryOptions; //导入依赖的package包/类
private Future<Void> importTx(StorableBlock block, JsonObject transactions) {
Future<Void> future = Future.future();
DeliveryOptions delivery = new DeliveryOptions().setSendTimeout(ONE_MINUTE);
if (config.isTxImport()) {
context.bus().send(TX_ADDR, transactions, delivery, done -> {
listener.onImported(block.getHash(), block.getNumber());
if (done.succeeded()) {
Throwable result = (Throwable) done.result().body();
if (result == null) {
future.complete();
} else {
future.fail(result);
}
} else {
future.fail(done.cause());
}
});
} else {
future.complete();
}
return future;
}
示例4: getPortfolio
import io.vertx.core.eventbus.DeliveryOptions; //导入依赖的package包/类
public void getPortfolio(Handler<AsyncResult<Portfolio>> resultHandler) {
if (closed) {
resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
return;
}
JsonObject _json = new JsonObject();
DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions();
_deliveryOptions.addHeader("action", "getPortfolio");
_vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
if (res.failed()) {
resultHandler.handle(Future.failedFuture(res.cause()));
} else {
resultHandler.handle(Future.succeededFuture(res.result().body() == null ? null : new Portfolio(res.result().body())));
}
});
}
示例5: buy
import io.vertx.core.eventbus.DeliveryOptions; //导入依赖的package包/类
public void buy(int amount, JsonObject quote, Handler<AsyncResult<Portfolio>> resultHandler) {
if (closed) {
resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
return;
}
JsonObject _json = new JsonObject();
_json.put("amount", amount);
_json.put("quote", quote);
DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions();
_deliveryOptions.addHeader("action", "buy");
_vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
if (res.failed()) {
resultHandler.handle(Future.failedFuture(res.cause()));
} else {
resultHandler.handle(Future.succeededFuture(res.result().body() == null ? null : new Portfolio(res.result().body())));
}
});
}
示例6: sell
import io.vertx.core.eventbus.DeliveryOptions; //导入依赖的package包/类
public void sell(int amount, JsonObject quote, Handler<AsyncResult<Portfolio>> resultHandler) {
if (closed) {
resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
return;
}
JsonObject _json = new JsonObject();
_json.put("amount", amount);
_json.put("quote", quote);
DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions();
_deliveryOptions.addHeader("action", "sell");
_vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
if (res.failed()) {
resultHandler.handle(Future.failedFuture(res.cause()));
} else {
resultHandler.handle(Future.succeededFuture(res.result().body() == null ? null : new Portfolio(res.result().body())));
}
});
}
示例7: evaluate
import io.vertx.core.eventbus.DeliveryOptions; //导入依赖的package包/类
public void evaluate(Handler<AsyncResult<Double>> resultHandler) {
if (closed) {
resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
return;
}
JsonObject _json = new JsonObject();
DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions();
_deliveryOptions.addHeader("action", "evaluate");
_vertx.eventBus().<Double>send(_address, _json, _deliveryOptions, res -> {
if (res.failed()) {
resultHandler.handle(Future.failedFuture(res.cause()));
} else {
resultHandler.handle(Future.succeededFuture(res.result().body()));
}
});
}
示例8: createNotification
import io.vertx.core.eventbus.DeliveryOptions; //导入依赖的package包/类
public NotificationService createNotification(Handler<AsyncResult<JsonObject>> resultHandler) {
if (closed) {
resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
return this;
}
JsonObject _json = new JsonObject();
DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions();
_deliveryOptions.addHeader("action", "createNotification");
_vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
if (res.failed()) {
resultHandler.handle(Future.failedFuture(res.cause()));
} else {
resultHandler.handle(Future.succeededFuture(res.result().body()));
}
});
return this;
}
示例9: send
import io.vertx.core.eventbus.DeliveryOptions; //导入依赖的package包/类
public MailService send(MailMessage message, Handler<AsyncResult<MailResult>> resultHandler) {
if (closed) {
resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
return this;
}
JsonObject _json = new JsonObject();
_json.put("message", message == null ? null : message.toJson());
DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions();
_deliveryOptions.addHeader("action", "send");
_vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
if (res.failed()) {
resultHandler.handle(Future.failedFuture(res.cause()));
} else {
resultHandler.handle(Future.succeededFuture(res.result().body() == null ? null : new MailResult(res.result().body())));
}
});
return this;
}
示例10: getConfiguration
import io.vertx.core.eventbus.DeliveryOptions; //导入依赖的package包/类
public ConfigurationProvider getConfiguration(String name, Handler<AsyncResult<JsonObject>> resultHandler) {
if (closed) {
resultHandler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
return this;
}
JsonObject _json = new JsonObject();
_json.put("name", name);
DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions();
_deliveryOptions.addHeader("action", "getConfiguration");
_vertx.eventBus().<JsonObject>send(_address, _json, _deliveryOptions, res -> {
if (res.failed()) {
resultHandler.handle(Future.failedFuture(res.cause()));
} else {
resultHandler.handle(Future.succeededFuture(res.result().body()));
}
});
return this;
}
示例11: startProcessWithVariables
import io.vertx.core.eventbus.DeliveryOptions; //导入依赖的package包/类
public ProcessService startProcessWithVariables(String processId, JsonObject jsonObject, Handler<AsyncResult<ProcessInstanceService>> handler) {
if (closed) {
handler.handle(Future.failedFuture(new IllegalStateException("Proxy is closed")));
return this;
}
JsonObject _json = new JsonObject();
_json.put("processId", processId);
_json.put("jsonObject", jsonObject);
DeliveryOptions _deliveryOptions = (_options != null) ? new DeliveryOptions(_options) : new DeliveryOptions();
_deliveryOptions.addHeader("action", "startProcessWithVariables");
_vertx.eventBus().<ProcessInstanceService>send(_address, _json, _deliveryOptions, res -> {
if (res.failed()) {
handler.handle(Future.failedFuture(res.cause()));
} else {
String addr = res.result().headers().get("proxyaddr");
handler.handle(Future.succeededFuture(ProxyHelper.createProxy(ProcessInstanceService.class, _vertx, addr)));
}
});
return this;
}
示例12: testWithMockWithASingleMessageHeadersNotCopied
import io.vertx.core.eventbus.DeliveryOptions; //导入依赖的package包/类
@Test
public void testWithMockWithASingleMessageHeadersNotCopied() throws Exception {
MockEndpoint endpoint = (MockEndpoint) camel.getComponent("mock").createEndpoint("mock:foo");
camel.addEndpoint("output", endpoint);
bridge = CamelBridge.create(vertx, new CamelBridgeOptions(camel)
.addOutboundMapping(fromVertx("test").toCamel("output").withoutHeadersCopy()));
camel.start();
BridgeHelper.startBlocking(bridge);
vertx.eventBus().send("test", "hello", new DeliveryOptions().addHeader("key", "value"));
await().atMost(DEFAULT_TIMEOUT).until(() -> !endpoint.getExchanges().isEmpty());
endpoint.expectedBodiesReceived("hello");
Exchange exchange = endpoint.getExchanges().get(0);
assertThat(exchange.getIn().getBody()).isEqualTo("hello");
assertThat(exchange.getIn().getHeaders()).doesNotContainKey("key");
}
示例13: testTheCopyOfHeaders
import io.vertx.core.eventbus.DeliveryOptions; //导入依赖的package包/类
@Test
public void testTheCopyOfHeaders() {
Message msg = new DefaultMessage();
msg.setHeader("CamelRedelivered", false);
msg.setHeader("CamelRedeliveryCounter", 0);
msg.setHeader("JMSCorrelationID", "");
msg.setHeader("JMSDestination", "queue://dev.msy.queue.log.fwd");
msg.setHeader("JMSReplyTo", null);
DeliveryOptions options = CamelHelper.getDeliveryOptions(msg, true);
assertThat(options.getHeaders().get("CamelRedelivered")).isEqualToIgnoringCase("false");
assertThat(options.getHeaders().get("CamelRedeliveryCounter")).isEqualToIgnoringCase("0");
assertThat(options.getHeaders().get("JMSCorrelationID")).isEqualToIgnoringCase("");
assertThat(options.getHeaders().get("JMSDestination")).isEqualToIgnoringCase("queue://dev.msy.queue.log.fwd");
assertThat(options.getHeaders().get("JMSReplyTo")).isNull();
}
示例14: convert
import io.vertx.core.eventbus.DeliveryOptions; //导入依赖的package包/类
@Override
public MessageHandler<T> convert(Flow flow) {
return message -> {
try {
flow.<Msg>start(
Msg.<T>builder()
.context(new ContextImpl(ImmutableMap.of()))
.headers(new HeadersImpl(
ComposerUtils.toListMultimap(message.headers()),
convertersMap.getMap()
))
.userId(userIdConverter.convert(message.headers().get(UserModel.userId)))
.body(message.body())
.build())
.then(msg -> message.reply(msg.body(), new DeliveryOptions().setHeaders(new VertxMultiMap(msg.headers().getMultimap()))))
.err(throwable -> messageProcessingErrorHandler.handleError(throwable, message));
} catch (Exception ex) {
messageProcessingErrorHandler.handleError(ex, message);
}
};
}
示例15: handle
import io.vertx.core.eventbus.DeliveryOptions; //导入依赖的package包/类
@Override
public Promise<StateTrigger<Msg<Object>>> handle(Msg<Object> msg) throws Throwable {
messageBus.publish(
MessageBus.Params.builder()
.address(eventAddress)
.message(msg.body())
.options(
new DeliveryOptions()
.setHeaders(
ComposerUtils.toVertxMultimap(msg.headers().getMultimap())
)
)
.build()
);
return Promises.of(
Flow.trigger(Events.next, msg)
);
}