Thursday, January 29, 2009

POJOs can route too!

In Camel we have several really cool Domain Specific Languages (DSLs) for easily expressing routing rules. But you don't need to learn these to use Camel. Starting with a POJO, you can use annotations to produce, consume or route messages to any Camel endpoint.

Take the following bean for example

public class BeanThatTalksCamel {
@Produce(uri="activemq:myQueue")
ProducerTemplate producer;

@Consume(uri = "file:a/path")
public void onFileSendToQueue(String body) {
producer.sendBody(body);
}
}


We use the @Consume annotation to mark onFileSendToQueue as a consumer of any messages coming from the file:a/path endpoint. To enable the bean to send messages to the activemq:myQueue endpoint, we use the @Produce annotation. All conversions between Files, Strings and JMS Messages are automatic. Pretty easy huh?

We also have the @RecipientList annotation that turns any bean into a dynamic Recipient List.


public class RecipientListBean {
@Consume(uri = "activemq:myQueue")
@RecipientList
public List route(String body) {
// return list of recipients based on message body
}
}


Here we consume JMS messages from myQueue and based on the body, send it out to a list of recipients. Again, very easy. If you're a ServiceMix user, Gert mentions how to use this trick from a ServiceMix perspective too, go check it out!

If you need more info, I've put all of these concepts into a little demo here. As always, if you need help using Camel, please get in touch.

Monday, January 26, 2009

Helpful Maven Build Tips

Brian Fox recently posted some great tips to improve your Maven builds. You should check them out if you haven't already. I've been doing most of what he said already but one really caught my attention, and I will repost here:

#6 Print Test Failures to Standard Output

Tip: Enable -Dsurefire.useFile=false. This is a favorite of mine since this causes surefire to print test failures to standard out, where it will get included in the build failure log and email. This saves you from having to dig back onto the machine to find the surefire report just to see a simple stack trace. (to enable globally in settings.xml:true in an active profile)


I can't believe I didn't know about this option before. Having to grep through surefire log files has really annoyed me in the past... many kudos to Brian for sharing this!

Tuesday, January 20, 2009

Camel is now an Apache top level project!

As James and Claus have said today, Camel has been promoted to a top level project at Apache! This is a great vote of confidence for Camel, my fellow riders, and the rocking community. Thanks to all who've helped so far!

So, you should update your links to http://camel.apache.org now :)

Wednesday, December 10, 2008

RSS support in Camel

We've had Atom connectivity in Camel for a while now and so to not leave any RSS users out in the cold, I put in RSS support as well. We try to integrate with pretty much every messaging system in Camel after-all :)

Under the hood I'm using the ROME project. Its pretty much the standard Java framework for dealing with RSS feeds.

To consume from an RSS feed, just start your route like

from("rss:http://feeds.feedburner.com/JonAnsteysBlog")...

Then you can do all sorts of neat stuff like,

Filtering entries

Only entries with Camel in the title will get through this filter.

from("rss:feedUri?splitEntries=true").
filter().method("myFilterBean", "titleContainsCamel").
to("mock:result");

Merging multiple incoming feeds

Sometimes you may need to merge feeds from several different sources.

from("rss:feedUri").to("seda:temp");
from("rss:someOtherFeedUri").to("seda:temp");

from("seda:temp").aggregate(new AggregateRssFeedCollection()).
to("mock:result");

Marshal between XML and ROME objects

Here we perform the same filtering as above but instead marshal to XML and use XPath.

from("rss:feedUri?splitEntries=true").
marshal().rss().
filter().xpath("//item/title[contains(.,'Camel')]").
to("mock:result");

For more info, check out the wiki documentation.

Wednesday, November 12, 2008

How do you use your Apache Camel?


The Apache Camel project has been growing by leaps and bounds lately it seems. Much of this growth has been driven by a vibrant community (many thanks to all users! :) ). Its typically hard though to know what kind of applications Camel is being used in. We don't have much visibility into the cool stuff people are doing with Camel. In particular, in would be nice to know what other applications are being used with Camel... eg. CMSs, DBs, ESBs, App Servers, web frameworks, other frameworks, etc etc

I've started a thread here trying to capture how folks are using Camel. Please, if you're a user of Camel, take a minute to share how it is being used on the thread or here. This will only help us make Camel better and more useful in the future. No confidential info allowed, of course ;)

Wednesday, November 5, 2008

Creating Apache Camel projects with m2eclipse

I just noticed today that Apache Camel shows up by default in the m2eclipse New Maven Project dialog. No extra fooling around is required anymore. Very cool!


This is by far the easiest way to get started with Apache Camel - you don't even have to leave your IDE.

Friday, October 31, 2008

Apache Camel 1.5.0 Released!


Several months and 266 fixes later (a new record!), the Apache Camel team is proud to present version 1.5.0!

Go ahead, take a look at the release notes and grab it here. Its still pretty fresh so it may take a few hours before the release propagates to all Apache download mirrors (try here otherwise).