本文整理汇总了Java中io.vertx.core.eventbus.EventBus.publish方法的典型用法代码示例。如果您正苦于以下问题:Java EventBus.publish方法的具体用法?Java EventBus.publish怎么用?Java EventBus.publish使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.vertx.core.eventbus.EventBus
的用法示例。
在下文中一共展示了EventBus.publish方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processOneResult
import io.vertx.core.eventbus.EventBus; //导入方法依赖的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: startRegistry
import io.vertx.core.eventbus.EventBus; //导入方法依赖的package包/类
private void startRegistry(final ServidorOptions options) {
// Rpc Agent is only valid in Micro mode
final EventBus bus = this.vertx.eventBus();
final String address = ID.Addr.IPC_START;
LOGGER.info(Info.IPC_REGISTRY_SEND, getClass().getSimpleName(), options.getName(), address);
bus.publish(address, options.toJson());
}
示例3: startRegistry
import io.vertx.core.eventbus.EventBus; //导入方法依赖的package包/类
private void startRegistry(final String name,
final HttpServerOptions options,
final Set<String> tree) {
// Enabled micro mode.
if (EtcdData.enabled()) {
final JsonObject data = getMessage(name, options, tree);
// Send Data to Event Bus
final EventBus bus = this.vertx.eventBus();
final String address = ID.Addr.REGISTRY_START;
LOGGER.info(Info.MICRO_REGISTRY_SEND, getClass().getSimpleName(), name, address);
bus.publish(address, data);
}
}
示例4: process
import io.vertx.core.eventbus.EventBus; //导入方法依赖的package包/类
@Override
public boolean process(Exchange exchange, AsyncCallback callback) {
EventBus eventBus = getEndpoint().getEventBus();
if (eventBus == null) {
exchange.setException(new IllegalStateException("EventBus is not started or not configured"));
callback.done(true);
return true;
}
String address = getEndpoint().getAddress();
boolean reply = ExchangeHelper.isOutCapable(exchange);
boolean pubSub = getEndpoint().isPubSub();
Object body = getVertxBody(exchange);
if (body != null) {
if (reply) {
LOG.debug("Sending to: {} with body: {}", address, body);
eventBus.send(address, body, new CamelReplyHandler(exchange, callback));
return false;
} else {
if (pubSub) {
LOG.debug("Publishing to: {} with body: {}", address, body);
eventBus.publish(address, body);
} else {
LOG.debug("Sending to: {} with body: {}", address, body);
eventBus.send(address, body);
}
callback.done(true);
return true;
}
}
exchange.setException(new InvalidPayloadRuntimeException(exchange, String.class));
callback.done(true);
return true;
}
示例5: openHandler
import io.vertx.core.eventbus.EventBus; //导入方法依赖的package包/类
@OnOpen
public void openHandler(SockJSSocket socket, EventBus eventBus) {
eventBus.publish(EB_ADDRESS, "opened");
}
示例6: closeHandler
import io.vertx.core.eventbus.EventBus; //导入方法依赖的package包/类
@OnClose
public void closeHandler(SockJSSocket socket, EventBus eventBus) {
eventBus.publish(EB_ADDRESS, "closed");
}
示例7: publish
import io.vertx.core.eventbus.EventBus; //导入方法依赖的package包/类
/**
* Sends a text frame on the socket.
*
* @param message the message
* @param bus the Vert.x event bus.
*/
public void publish(String message, EventBus bus) {
bus.publish(getWriteHandlerId(), message);
}