当前位置: 首页>>代码示例>>Java>>正文


Java EventBus.publish方法代码示例

本文整理汇总了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);
				}
			});
		}
	}
 
开发者ID:Stwissel,项目名称:vertx-sfdc-platformevents,代码行数:27,代码来源:CometD.java

示例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());
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:8,代码来源:ZeroRpcAgent.java

示例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);
    }
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:14,代码来源:ZeroHttpAgent.java

示例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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:38,代码来源:VertxProducer.java

示例5: openHandler

import io.vertx.core.eventbus.EventBus; //导入方法依赖的package包/类
@OnOpen
public void openHandler(SockJSSocket socket, EventBus eventBus) {
	eventBus.publish(EB_ADDRESS, "opened");
}
 
开发者ID:aesteve,项目名称:nubes,代码行数:5,代码来源:TestSockJSController.java

示例6: closeHandler

import io.vertx.core.eventbus.EventBus; //导入方法依赖的package包/类
@OnClose
public void closeHandler(SockJSSocket socket, EventBus eventBus) {
	eventBus.publish(EB_ADDRESS, "closed");
}
 
开发者ID:aesteve,项目名称:nubes,代码行数:5,代码来源:TestSockJSController.java

示例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);
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:10,代码来源:Socket.java


注:本文中的io.vertx.core.eventbus.EventBus.publish方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。