apache-camelvert.x

Vertx and Camel Integration


I'm trying to figure out what the best way to send messages from an Apache Camel route to an external Vert.x event bus.

I have looked at the camel-vertx library and the vertx-camel-bridge, but these libraries appear to be used for communicating between Camel and Vert.x running in the same JVM and I'm not seeing any examples with Camel and Vert.x running separately.

Is my assumption correct? And would ActiveMQ be a good bridge between Vertx and Camel?


Solution

  • The Vert.x event bus can be clustered. On one node (A), you can have a pure Vert.x application sending messages. On the other node (B), you can have your Camel application with the Vert.x Camel bridge.

    On node A:

    vertx.eventBus().send("eventbus-address", "a message");
    

    On node B:

    CamelContext camel = new DefaultCamelContext();
    OutboundMapping outbound = OutboundMapping
      .fromVertx("eventbus-address")
      .toCamel("stream:out");
    CamelBridge.create(vertx, new CamelBridgeOptions(camel)
      .addOutboundMapping(outbound)).start();