Enterprise Java

Apache Camel 3 – camel-core vs camel-core-engine (smaller core)

The Camel team is very busy currently working on Apache Camel 3. A lot of work has already been implemented and we have released 3 milestone releases so far. The next milestone release number 4 has some great new innovative features which I will blog about in the following months.

The topic of this blog is the work we have been doing on splitting up camel-core into smaller modules which you can now easily pick exactly only what you need.

If we take a look at the dependency tree of the camel-core JAR you can see that it’s been split up into many modules as shown below:

[INFO] +- org.apache.camel:camel-core:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-api:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-base:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-jaxp:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-management-api:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-support:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-util:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-util-json:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-bean:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-browse:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-caffeine-lrucache:jar:3.0.0-SNAPSHOT:compile
[INFO] |  |  \- com.github.ben-manes.caffeine:caffeine:jar:2.7.0:compile
[INFO] |  |     +- org.checkerframework:checker-qual:jar:2.6.0:compile
[INFO] |  |     \- com.google.errorprone:error_prone_annotations:jar:2.3.3:compile
[INFO] |  +- org.apache.camel:camel-controlbus:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-dataformat:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-dataset:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-direct:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-directvm:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-file:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-language:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-log:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-mock:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-properties:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-ref:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-rest:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-saga:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-scheduler:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-seda:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-stub:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-timer:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-validator:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-vm:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-xpath:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-xslt:jar:3.0.0-SNAPSHOT:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.25:compile

In Camel 2.x all those modules were included in the same camel-core JAR.

To make the migration from Camel 2.x to 3.0 and also the ease of use, we will keep camel-core as the same set of JAR dependencies as in Camel 2.x. So the output above is from just declaring a dependency on camel-core, in your Maven pom.xml file or gradle build file.

However what is coming in Camel 3 milestone 4, is to make it easy as well to just pick what you need. For example the following shows a the dependency tree where we are only using as little as possible (using the new camel-core-engine JAR as dependency):

+- org.apache.camel:camel-core-engine:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-api:jar:3.0.0-SNAPSHOT:compile
[INFO] |  |  \- org.apache.camel:camel-util:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-management-api:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-support:jar:3.0.0-SNAPSHOT:compile
[INFO] |  \- org.apache.camel:camel-core:jar:3.0.0-SNAPSHOT:compile
[INFO] |     +- org.apache.camel:camel-base:jar:3.0.0-SNAPSHOT:compile
[INFO] |     \- org.apache.camel:camel-properties:jar:3.0.0-SNAPSHOT:compile

To illustrate this we have provided 2 set of examples

The former uses the camel-core as dependency which includes all the core components etc. The latter is the tiny dependency set, which only includes what is needed. The example only uses the bean and quartz2 component and therefore you would need to add them as dependency:

The dependency tree is as follows (mind that JAXB is excluded as test scope)

[INFO] --- maven-dependency-plugin:3.1.1:tree (default-cli) @ camel-example-main-tiny ---
[INFO] org.apache.camel.example:camel-example-main-tiny:jar:3.0.0-SNAPSHOT
[INFO] +- org.apache.camel:camel-core-engine:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-api:jar:3.0.0-SNAPSHOT:compile
[INFO] |  |  \- org.apache.camel:camel-util:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-management-api:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.apache.camel:camel-support:jar:3.0.0-SNAPSHOT:compile
[INFO] |  \- org.apache.camel:camel-core:jar:3.0.0-SNAPSHOT:compile
[INFO] |     +- org.apache.camel:camel-base:jar:3.0.0-SNAPSHOT:compile
[INFO] |     \- org.apache.camel:camel-properties:jar:3.0.0-SNAPSHOT:compile
[INFO] +- org.apache.camel:camel-main:jar:3.0.0-SNAPSHOT:compile
[INFO] +- org.apache.camel:camel-bean:jar:3.0.0-SNAPSHOT:compile
[INFO] +- org.apache.camel:camel-quartz2:jar:3.0.0-SNAPSHOT:compile
[INFO] |  +- org.quartz-scheduler:quartz:jar:2.3.1:compile
[INFO] |  |  +- com.mchange:mchange-commons-java:jar:0.2.15:compile
[INFO] |  |  \- com.zaxxer:HikariCP-java7:jar:2.4.13:compile
[INFO] |  \- com.mchange:c3p0:jar:0.9.5.4:compile
[INFO] +- com.sun.xml.bind:jaxb-core:jar:2.3.0:test
[INFO] +- com.sun.xml.bind:jaxb-impl:jar:2.3.0:test
[INFO] +- org.apache.logging.log4j:log4j-api:jar:2.11.2:runtime
[INFO] +- ch.qos.logback:logback-core:jar:1.2.3:compile
[INFO] \- ch.qos.logback:logback-classic:jar:1.2.3:compile
[INFO]    \- org.slf4j:slf4j-api:jar:1.7.25:compile

If we compare the size of the JARs between the two examples (incl logger etc), then we have:

  • camel-example-main (camel-core): 48 JAR files with total of 9.3 MB
  • camel-example-main-tiny (camel-core-engine): 21 JAR files with total of 7.4 MB

If we run the two examples then you can also see the number of classes loaded into the JVM is a bit smaller when using camel-core-engine:

  • camel-example-main (camel-core): 3666 classes loaded
  • camel-example-main-tiny (camel-core-engine): 3430 classes loaded

Okay the reduction here is not as significant, but it is expected as Camel will lazy load components in use, and the example only uses the bean and quartz component. However the classpath scanning would be a bit faster as there are roughly 25% less disk-size and 50% less JAR files.

There are many other great things coming in Apache Camel 3 which I will start writing blogs about during this summer leading up to the release (expected in September/October 2019).

Published on Java Code Geeks with permission by Claus Ibsen, partner at our JCG program. See the original article here: Apache Camel 3 – camel-core vs camel-core-engine (smaller core)

Opinions expressed by Java Code Geeks contributors are their own.

Claus Ibsen

Claus Ibsen is a principal software engineer from Red Hat. Claus is working full time as Apache Camel committer. And is author of the "Camel in Action" book.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button