Taking Apache Camel for a Ride with Bruce Snyder
Camel is a Java API that allows you to do message routing very easily. It implements many of the patterns found in Enterprise Integration Patterns. It doesn't require a container and can be run in any Java-based environment. Camel has a whole bunch of components - Bruce is showing a 6 x 10 grid with a component name in each grid. In other words, there's 60 components that Camel can use. Examples include: ActiveMQ, SQL, Velocity, File and iBATIS.
Chris Richardson asks "What's left inside of ServiceMix". Why use ServiceMix if you have Camel? ServiceMix is a container that can run standalone or inside an app server. You can run distributed ServiceMix as a federated ESB. Camel is much smaller and lightweight and is really just a Java API. ServiceMix 4 changed from a JBI-based architecture to OSGi (based on Apache Felix). They also expect to create your routes for ServiceMix 4 with Camel instead of XML. To process messages, you can use many different languages: BeanShell, JavaScript, Groovy, Python, PHP, Ruby, JSP EL, OGNL, SQL, XPath and XQuery.
Camel has a CamelContext
that's similar to Spring's ApplicationContext
. You can initialize it in Java and add your routes to it:
CamelContext context = new DefaultCamelContext(); context.addRoutes(new MyRouterBuilder()); context.start();
Or you can initialize it using XML:
<camelContext xmlns="http://activemq.apache.org/camel/schema/spring"> <package>com.acme.routes</package> </camelContext>
Camel's RouteBuilder
contains a fluid API that allows you to define to/from and other criteria. At this point, Bruce is showing a number of examples using the Java API. He's showing a Content Based Router, a Message Filter, a Splitter, an Aggregator, a Message Translator, a Resequencer, a Throttler and a Delayer.
Bruce spent the last 10 minutes doing a demo using Eclipse, m2eclipse, the camel-maven-plugin and ActiveMQ. It's funny to see a command-line guy like Bruce say he can't live w/o m2eclipse. I guess Maven's XML isn't so great after all.
Camel is built on top of Spring and has good integration. Apparently, the Camel developers tried to get it added to Spring, but the SpringSource guys didn't want it. Coincidentally, Spring Integration was released about a year later.
Camel also allows you to use "beans" and bind them to Camel Endpoints with annotations. For example:
public class Foo { @MessageDriven (uri="activemq:cheese") public void onCheese(String name) { ... } }
Other annotations include @XPath, @Header and @EndpointInject.
Camel can also be used for BAM (Business Activity Monitoring). Rather than using RouteBuilder, you can use ActivityBuilder to listen for activities and create event notifications.
Bruce had quite a few folks show up for this presentation. I had trouble finding a seat because I was late. I think he did a good job of showing what Camel is and how you might use it.
Posted by 219.238.94.93 on October 30, 2008 at 02:02 AM MDT #
Yes, Camel provides integration with the Spring Framework. For more information, see the following doc:
http://activemq.apache.org/camel/spring.html
Posted by Bruce Snyder on October 30, 2008 at 04:06 AM MDT #