Package org.vertx.java.core.eventbus

Examples of org.vertx.java.core.eventbus.EventBus


    public VertxEndpoint getEndpoint() {
        return (VertxEndpoint) super.getEndpoint();
    }

    public void process(Exchange exchange) throws Exception {
        EventBus eventBus = getEndpoint().getEventBus();
        String address = getEndpoint().getAddress();

        Message in = exchange.getIn();

        JsonObject jsonObject = in.getBody(JsonObject.class);
        if (jsonObject != null) {
            LOG.debug("Publishing to: {} with JsonObject: {}", address, jsonObject);
            eventBus.publish(address, jsonObject);
            return;
        }
        JsonArray jsonArray = in.getBody(JsonArray.class);
        if (jsonArray != null) {
            LOG.debug("Publishing to: {} with JsonArray: {}", address, jsonArray);
            eventBus.publish(address, jsonArray);
            return;
        }

        // and fallback and use string which almost all can be converted
        String text = in.getBody(String.class);
        if (text != null) {
            LOG.debug("Publishing to: {} with String: {}", address, text);
            eventBus.publish(address, new JsonObject(text));
            return;
        }
        throw new InvalidPayloadRuntimeException(exchange, String.class);
    }
View Full Code Here

TOP

Related Classes of org.vertx.java.core.eventbus.EventBus

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.