Camel in Action - 2 years later

Two years ago the Camel in Action book was done and published.

Camel in Action, published January 2011
So when we started the journey of the book we knew we had once shot of getting this right. So Jonathan and I went all in, and worked our socks off to deliver a quality book, that do justice to the fantastic project that Apache Camel is.

So with all the hard work Jonathan and I put into it, what did we get from this? Well it was not really about the money, as that can't cover cost of living. Though to treat myself good I purchased a coffee machine - which I still enjoy using ever day; the coffee tast really good.

The community liked the book and have gotten good reviews. Looking today at the Amazon site, we have 10 top-mark reviews. The last review is as late as December 26th 2012, so people are still finding this book useful.

Ten 5-star customer reviews of the Camel in Action book from Amazon
The book seems to go well over the years, for example the last quarterly sales figures I have (Q2 2012), the book sold 701 units. 

As previous said, Jonathan and I, went all in with this book. So after the book was published, we have keep to our toes, and ensured that we keep the following up to date:
Sidenote: As a reader of other books, this is not always the case, where the authors have this devotion to their book. As a reader I fell disappointed to get started with a book, and the source code is outdated, and don't compile/work anymore. Or that mistakes in the book is not pointed out in an errata. And when I want to interact with the authors, they are not responsive on the official book forum. 
When our readers find a mistake in the book, they report that to us on the book forum, or by sending private emails. We then take a look, and if there is a mistake, make sure to get the errata updated, and submit that to Manning; whom them publish the update on the book site. For example the last errata update is from July 2012.

Over the years since the book was published, we have released new versions of Apache Camel. So as a courtesy to new readers we are keeping the books source code in sync with the Camel releases. We only missed the Camel 2.6.0 release which was the 1st release after the book was published. So today we have 13 updates to the source code available for our readers.

Source code for the Camel in Action book, updated with the following Apache Camel releases.
The source code for the book has also been useful to the Camel team. So every time we are working on a new release, we run that release against the source code of the book, to test for any regressions etc. Over the time we have actually found a number of bugs, which we could fix before cutting the release.

So what's next? Well thats a story for another blog entry, if/when that story starts...


Camel 2.11 - Camel web applications without Spring

So today we are in the year of 2013.

And as I write this we have just added a new component to the upcoming Apache Camel 2.11, that allow to run web applications with Camel without having to rely on Spring Framework to boostrap Camel. Or any other 3rd party frameworks for that matter.

A bit ashamed to say that in the year 2013 we are a bit late to the party to offer this out of the box in Apache Camel.

In modern web containers supporting Servlet 3.0 spec. you can programmatically bootstrap your code using the new @WebListener annotation. But even so there is still work to be done, as you would need to setup and configure Camel, and as well ensure resources is unregistered and stopped when stopping the web application.

I have not found a neat way of using @WebListener and allowing external configuration of your framework such as Apache Camel. I dont really want to hardcode my configuration, or have to invent my own way of loading external configuration and configure my application. Anyone know of a solution to this problem?

Anyway we also wanted a solution that works for old school Servlet 2.x based container. There is a ton of them out there running. And even so the old school configuration with a web.xml file works just as good in the newer Servlet 3.0 containers. So we wanted an out of the box solution that fit both worlds.

Example to showcase

We have a number of examples at Apache Camel, and one is a simple web application that is ready to be deployed as a .war file in Apache Tomcat, or any other web container.

This example is using the Spring Framework to boostrap a Spring XML file, where we have Camel embedded. So what we did was to redo this example without the need for Spring.

The two examples is documented at the Apache Camel site at:


In Camel 2.11 we have a new component named camel-servletlistener, which offers a new CamelServletContextListener class which you configure in the web.xml file. This will then boostrap a CamelContext, and use the context init parameters as its configuration.

This context listener has a lot of configuration, so you can easily configure Camel to your needs.
The options is listed in the Camel docs at: http://camel.apache.org/servletlistener-component.html

And in case you need to execute any custom logic when Camel is starting/stopping then we have an API for that, a CamelContextLifecycle interface. There is more details and examples at the Camel docs.

To see this in action, I suggest after reading this blog, check out the new example, as well the documentation for the camel-servletlistener component.

Dissecting the example

Having the two examples

We can take a peak at the difference between the two of them, when deploying to fresh installation of Apache Tomcat 7.0.30 using Java 1.6. 

size: 5.8 MB
jars: 19
classes loaded: 4507
current heap size: 10 MB

size: 2.9 MB
jars: 10
classes loaded: 3698
current heap size: 8 MB

I used jconsole to look at the number of loaded classes in the JVM with the Apache Tomcat and the deployed example. The heap size was measured as the lowest value I could get after performing GC.

So we cut 10 JARs and 3MB from the distribution. As well avoid loading in the shy of 1000 classes.


I just want to emphasize that the goal of this new camel-servletlistener component is to allow people to easily bootstrap their Camel applications in any web container, without the need to be tied to any particular 3rd party framework such as Spring. The Apache Camel project aims to be neutral and agnostic; allowing people to run Camel in any way and container of choice.