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);
}