New Camel Example to Compare With Spring Integration Simple Example
Join the DZone community and get the full member experience.Join For Free
So this morning I read the new blog post by Gunnar, how to create a Spring Integration project in STS tooling, which is posted here. The STS creates a simple out of the box example, that provides the following XML (in screenshot) as the main logic. Take a moment to see if you can figure out what it does. And then compare to the equivalent Camel example below.
|Spring Integration - Simple Example created by STS tooling|
|Apache Camel - The same example as above|
- reads input from the console
- upper case the input
- and prints it back on the console
This example will be provided out of the box in the upcoming Apache Camel 2.10, in the examples/camel-example-console directory. You can see the source code here.
You can run it from command line using Maven
mvn compile exec:java
And then press ctrl + c to stop the application.
|Running the Camel example from command line|
|Running the example from your editor such as IDEA|
To create a new Camel project you can use the Camel Maven archetypes. Or use Fuse IDE which has a wizard just like STS to create a new Camel project.
A few notes about Camel. The example uses Spring and XML, however Camel can be used without Spring at all. We could use pure Java and define the Camel route in a Java class. You can also use Scala. And for XML we could also have used OSGi Blueprint.
With Camel you simply have more choices, and dont have to use XML at all.
Published at DZone with permission of Claus Ibsen, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.