本文整理汇总了Java中io.vertx.core.eventbus.DeliveryOptions.setSendTimeout方法的典型用法代码示例。如果您正苦于以下问题:Java DeliveryOptions.setSendTimeout方法的具体用法?Java DeliveryOptions.setSendTimeout怎么用?Java DeliveryOptions.setSendTimeout使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.core.eventbus.DeliveryOptions
的用法示例。
在下文中一共展示了DeliveryOptions.setSendTimeout方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeHandler
import io.vertx.core.eventbus.DeliveryOptions; //导入方法依赖的package包/类
private KafkaConsumerHandler makeHandler(final KafkaConsumerConfiguration configuration, final String vertxAddress) {
return (message, futureResult) -> {
final DeliveryOptions options = new DeliveryOptions();
options.setSendTimeout(configuration.getEventBusSendTimeout());
vertx.eventBus().send(vertxAddress, message, options, (result) -> {
if (result.succeeded()) {
futureResult.complete();
} else {
futureResult.fail(result.cause());
}
});
};
}
示例2: process
import io.vertx.core.eventbus.DeliveryOptions; //导入方法依赖的package包/类
@Override
public boolean process(Exchange exchange, AsyncCallback callback) {
Message in = exchange.getIn();
Object body = CamelHelper.convert(inbound, in);
DeliveryOptions delivery = CamelHelper.getDeliveryOptions(in, inbound.isHeadersCopy());
if (inbound.getTimeout() > 0) {
delivery.setSendTimeout(inbound.getTimeout());
}
try {
if (inbound.isPublish()) {
vertx.eventBus().publish(inbound.getAddress(), body, delivery);
} else {
if (ExchangeHelper.isOutCapable(exchange)) {
vertx.eventBus().send(inbound.getAddress(), body, delivery, reply -> {
Message out = exchange.getOut();
if (reply.succeeded()) {
out.setBody(reply.result().body());
MultiMapHelper.toMap(reply.result().headers(), out.getHeaders());
} else {
exchange.setException(reply.cause());
}
// continue callback
callback.done(false);
});
// being routed async so return false
return false;
} else {
// No reply expected.
vertx.eventBus().send(inbound.getAddress(), body, delivery);
}
}
} catch (Throwable e) {
// Mark the exchange as "failed".
exchange.setException(e);
}
callback.done(true);
return true;
}