Search code examples
javaxmlapache-camelapache-servicemixblueprint-osgi

ServiceMix and Camel : How do I create routes?


This part of the puzzle is my nightmare, I have deployed ServiceMix, and 2 Java apps on 2 different tomcat instances :

First app :

http://localhost:8080/textmsgClient

Second app :

http://localhost:8181/textmsgServer

Now my two apps need to communicate, though I want that communication to go through ServiceMix, so I can do some logs and everything.

I've created a blueprint XML file in the ./deploy directory, but what routes should I put in them?

I can't do this :

  <route>
    <from uri="http://localhost:8080/textmsgClient"/>
    <log message="Test log"/>
    <to uri="http://localhost:8181/textmsgServer"/>
  </route>

so what is the correct thing to do ?

by the way, my XML file looks like this :

<?xml version="1.0" encoding="UTF-8"?>
<blueprint
    xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
      http://www.osgi.org/xmlns/blueprint/v1.0.0
      http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">

    <camelContext xmlns="http://camel.apache.org/schema/blueprint">
      <route>
        <from uri="file:camel/input"/>
        <log message="Moving ${file:name} to the output directory"/>
        <to uri="file:camel/output"/>
      </route>
    </camelContext>

</blueprint>

Solution

  • Take a look at the list of Camel Components. Not knowing what type of data you are sending between services, it is difficult to recommend which one to use. However, theres a component for pretty much every data type you can imagine, and even support to make your own!

    Edit An example might be:

    <route>
        <from uri="direct:textmsgClient"/>
        <log message="Test log"/>
        <to uri="direct:textmsgServer"/>
    </route>