本文整理匯總了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;
}