当前位置: 首页>>代码示例>>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;未经允许,请勿转载。