當前位置: 首頁>>代碼示例>>Java>>正文


Java EventBus.send方法代碼示例

本文整理匯總了Java中io.vertx.core.eventbus.EventBus.send方法的典型用法代碼示例。如果您正苦於以下問題:Java EventBus.send方法的具體用法?Java EventBus.send怎麽用?Java EventBus.send使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在io.vertx.core.eventbus.EventBus的用法示例。


在下文中一共展示了EventBus.send方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getAuthInfo

import io.vertx.core.eventbus.EventBus; //導入方法依賴的package包/類
/**
 * Check for the Authentication info if required
 *
 * @return a future that resolves when successful got AuthInfo
 */
private Future<AuthInfo> getAuthInfo() {
	Future<AuthInfo> result;
	final String authName = this.getConsumerConfig().getAuthName();
	if ((this.authInfo == null) && (authName != null)) {
		result = Future.future();
		final EventBus eb = this.getVertx().eventBus();
		final String address = Constants.BUS_AUTHREQUEST + authName;
		eb.send(address, null, replyHandler -> {
			if (replyHandler.succeeded()) {
				this.authInfo = (AuthInfo) replyHandler.result().body();
				result.complete(this.authInfo);
			} else {
				result.fail(replyHandler.cause());
			}
		});

	} else {
		result = Future.succeededFuture(this.authInfo);
	}
	return result;
}
 
開發者ID:Stwissel,項目名稱:vertx-sfdc-platformevents,代碼行數:27,代碼來源:RestConsumer.java

示例2: getAuthInfo

import io.vertx.core.eventbus.EventBus; //導入方法依賴的package包/類
private Future<AuthInfo> getAuthInfo() {
	Future<AuthInfo> result;
	if (this.authInfo == null) {
		result = Future.future();
		final EventBus eb = this.getVertx().eventBus();
		final String address = Constants.BUS_AUTHREQUEST + this.getListenerConfig().getAuthName();
		eb.send(address, null, replyHandler -> {
			if (replyHandler.succeeded()) {
				this.authInfo = (AuthInfo) replyHandler.result().body();
				result.complete(this.authInfo);
			} else {
				result.fail(replyHandler.cause());
			}
		});

	} else {
		result = Future.succeededFuture(this.authInfo);
	}
	return result;
}
 
開發者ID:Stwissel,項目名稱:vertx-sfdc-platformevents,代碼行數:21,代碼來源:CometD.java

示例3: scheduling

import io.vertx.core.eventbus.EventBus; //導入方法依賴的package包/類
static void scheduling(Vertx vertx) {
	EventBus eventBus = vertx.eventBus();
	// Consumer of the timer events
	MessageConsumer<JsonObject> consumer = eventBus.consumer("scheduler:timer");
	// Listens and prints timer events. When timer completes stops the Vertx 
	consumer.handler (
		message -> {
			JsonObject event = message.body();
			if (event.getString("event").equals("complete")) {
				System.out.println("completed");
				vertx.close();
			}
			else {
				System.out.println(event);
			}
	  	}
	);
	// Create new timer
	eventBus.send (
		"chime",
		(new JsonObject()).put("operation", "create").put("name", "scheduler:timer")
			.put("publish", false).put("max count", 3)
			.put("description", (new JsonObject()).put("type", "interval").put("delay", 1)),
		ar -> {
			if (ar.succeeded()) {
				System.out.println("Scheduling started: " + ar.result().body());
			}
			else {
				System.out.println("Message failed: " + ar.cause());
				vertx.close();
			}
		}
	);
}
 
開發者ID:LisiLisenok,項目名稱:ChimeJavaExample,代碼行數:35,代碼來源:Main.java

示例4: retry

import io.vertx.core.eventbus.EventBus; //導入方法依賴的package包/類
/**
 * Retry send request item to retry queue of planner
 */
private void retry() {
    int retried = request.getRetried();
    if (retried < retryTimes) {
        request.setRetried(retried + 1);
        EventBus eb = executor.getEventBus();
        eb.send(MessageAddress.RETRY_URL_LISTENER, request);
    } else {
        logger.error("Failed to download {} after {} retries!", url, retryTimes);
    }
}
 
開發者ID:ljie-PI,項目名稱:tentacles,代碼行數:14,代碼來源:Downloadable.java

示例5: 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

示例6: listenCurrentTrack

import io.vertx.core.eventbus.EventBus; //導入方法依賴的package包/類
static void listenCurrentTrack(final EventBus eventBus) {
    eventBus.consumer(TRACK_CHANGED).handler(event -> eventBus.publish(AUDIO_CURRENT, event.body()));
    eventBus.send(GET_CURRENT_TRACK, null, response -> {
        if (response.succeeded()) {
            eventBus.publish(AUDIO_CURRENT, response.result().body());
        } else {
            eventBus.publish(AUDIO_CURRENT, new JsonObject());
        }
    });
}
 
開發者ID:jotak,項目名稱:mipod.x,代碼行數:11,代碼來源:AudioConsumers.java

示例7: headers

import io.vertx.core.eventbus.EventBus; //導入方法依賴的package包/類
public void headers(EventBus eventBus) {
  DeliveryOptions options = new DeliveryOptions();
  options.addHeader("some-header", "some-value");
  eventBus.send("news.uk.sport", "Yay! Someone kicked a ball", options);
}
 
開發者ID:vert-x3,項目名稱:vertx-lang-groovy,代碼行數:6,代碼來源:Examples.java

示例8: handleRestRequest

import io.vertx.core.eventbus.EventBus; //導入方法依賴的package包/類
/**
 * handles REST requests
 *
 * @param eventBus   the vert.x event bus
 * @param request    the http request
 * @param url        the request URL
 * @param parameters the request parameters
 * @param mimes      the service mime types
 * @param timeout    the default timeout
 */
private void handleRestRequest(final EventBus eventBus,
                               HttpServerRequest request,
                               final String url,
                               final Parameter parameters,
                               final List<String> mimes,
                               final int timeout) {
    eventBus.
            send(
                    url,
                    getSerializedParameters(parameters),
                    new DeliveryOptions().setSendTimeout(timeout),
                    event -> createRestResponse(request, mimes, event));
}
 
開發者ID:amoAHCP,項目名稱:vert.x-microservice,代碼行數:24,代碼來源:LocalRESTHandler.java

示例9: forward

import io.vertx.core.eventbus.EventBus; //導入方法依賴的package包/類
private static void forward(BridgeEvent be, EventBus eb) {
	String type = be.type().toString();
	eb.send(type, type);
	be.complete(true);
}
 
開發者ID:aesteve,項目名稱:nubes,代碼行數:6,代碼來源:EBBridgeDefaultController.java

示例10: example10

import io.vertx.core.eventbus.EventBus; //導入方法依賴的package包/類
public void example10(EventBus eventBus, MessageCodec myCodec) {

    eventBus.registerCodec(myCodec);

    DeliveryOptions options = new DeliveryOptions().setCodecName(myCodec.name());

    eventBus.send("orders", new MyPOJO(), options);
  }
 
開發者ID:vert-x3,項目名稱:vertx-lang-groovy,代碼行數:9,代碼來源:Examples.java

示例11: example11

import io.vertx.core.eventbus.EventBus; //導入方法依賴的package包/類
public void example11(EventBus eventBus, MessageCodec myCodec) {

    eventBus.registerDefaultCodec(MyPOJO.class, myCodec);

    eventBus.send("orders", new MyPOJO());
  }
 
開發者ID:vert-x3,項目名稱:vertx-lang-groovy,代碼行數:7,代碼來源:Examples.java


注:本文中的io.vertx.core.eventbus.EventBus.send方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。