當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。