Apache Camel 2.9 - Reduced dependency on Spring JARs

One of the goals for Apache Camel 2.9 is to reduce dependency on Spring JARs in both the camel-core and other components.

In the core we used the Spring JMX annotations to more easily export Camel MBeans into JMX. This dependency is an optional dependency on Spring JARs as you would need those in case you want to manage Camel using JMX. Unfortunately Spring does not provide a light weight API for the JMX pieces, and you end up loading in 6+ Spring JARs. This is of course not desirable, so we moved forward a goal for Camel 3.0 to the upcoming Apache Camel 2.9 release, which is to provide a Camel set of JMX annotations and use pure Java JMX logic to enlist those.

This work has been carried out, and you can now use Camel JMX with no Spring JARs at all at runtime.

To be compatible with the Spring JMX annotations, we moved the old logic from camel-core to camel-spring component. So you can still use Spring JMX annotations in your custom Camel components / beans / processors etc. and have them enlisted in JMX, together with the other Camel MBeans.

The camel-core JAR in Camel 2.9 onwards now only depend on the SLF4j logging API. This is as low dependency we want to go.

The dependency tree report by Apache Maven is now simply:

[INFO] org.apache.camel:camel-core:bundle:2.9-SNAPSHOT
[INFO] +- org.slf4j:slf4j-api:jar:1.6.1:compile

A number of Camel components used the Spring IO Resource to load template files from the file system or classpath. This didn't work in OSGi blueprint containers, so we decided to use existing code from camel-core instead. This means a total of 11 components now do not depend on Spring JARs either. We also identified a component in camel-spring, which could be moved to camel-core. For example the XSLT component has now been moved from camel-spring to camel-core.

So what's left? Which components depend on Spring JARs? Well there is only camel-mail and camel-jms left. In the former we only use Spring to send emails, and there is a contribution from the community to use plain Java Mail API to send emails. So it should be a matter of time before camel-mail is migrated as well. The camel-jms component is built on top of spring-jms, especially its MessageListenerContainer abstraction. Therefore it is not feasible to remove Spring dependency. However we may consider creating a new light weight JMS component in the future, having less bells and whistles as the current component, but keeping it simpler and leaner.

So does this mean we dont like Spring? Well of course we do, but Spring is not the center of the universe. Apache Camel is used in a lot of different systems and environments. Its important that Camel can easily fit into your environment. For example if you use JEE then JEE containers offers a lot of the same capabilities as Spring does. Now you can more easily use JEE and Camel without dragging Spring along.

Apache Camel 2.9 will still be as powerful integrated with Spring as it has always been. There is no changes for any existing users who use Spring and Camel together.


Kai Wähner said...

Very good news! In many of my sessions at conferences, people ask about the Spring dependencies...

Best regards,
Kai Wähner (Twitter: @KaiWaehner)

George said...


Now I can start using Camel in more places, for example, it could serve as a great services layer for user applications.

Hope you guys will have a Spring-free IDE support one day :)