Camel Example
Apache Camel can be used to provide Enterprise Integration Patterns within JBI.
This example creates a Camel Service Unit and puts it into a Service Assembly for deploying a some Camel routes and EIP patterns in JBI.
You can find the example in the servicemix/samples/camel area.
Running the Example
There are a number of different ways to run the example...
Running the Example with jbi:servicemix
To run the example using an embedded ServiceMix container inside Maven you can use the Maven JBI plugin.
cd samples/camel
mvn install
cd camel-sa
mvn jbi:servicemix
This should build the Camel Service Unit (in samples/camel/camel-simple-su) and then deploy the Service Assembly in ServiceMix.
Deploying the Example in ServiceMix
Using this option we'll first need to start ServiceMix, for example by running the following from a binary distro...
Now we build the Service Assembly
cd samples/camel
mvn install
Now we can deploy the Service Assembly using the Maven JBI plugin
cd camel-sa
mvn jbi:projectDeploy
Alternatively you could just copy the Service Assembly jar into the hotdeploy directory of the running ServiceMix container
Code Walkthrough
The Service Assembly just contains a single Service Unit, camel-simple-su, so thats where all the action is.
If you look inside samples/camel/camel-simple-su you will see...
- the Camel routes are defined in Java via src/main/java/org/apache/servicemix/samples/MyRouteBuilder.java. This actually defines a pretty trivial route; which just creates a timer so that every second a message is sent to a log endpoint (to log to the console) so its easy to see the Camel route working inside ServiceMix
- the Service Unit is configured via the Spring src/main/resources/camel-context.xml, in particular the <package> element points to the org.apache.servicemix.samples package so that MyRouteBuilder will be enabled by default.