Published on

Camel Quarkus 1.0.0 Released

Authors
  • avatar
    Name
    James Netherton
    Twitter

Apache Camel Quarkus 1.0.0 has been announced as GA.

Since I've been contributing to the project for the past months, I thought it'd be a good time to write a post that explores the rationale behind the project and some its core features.

Camel Quarkus Project

The Camel Quarkus project aims to bring the awesome integration capabilities of Apache Camel and its vast component library to the Quarkus runtime.

This enables users to take advantage of the performance benefits, developer joy and the container first ethos that Quarkus provides.

Camel Quarkus provides Quarkus extensions for many of the Camel components. At present around 180 components have extensions with more planned in the future.

Camel Quarkus also takes advantage of the many performance improvements made in Camel 3, which results in a lower memory footprint, less reliance on reflection (which is good for native application support) and faster startup times.

You can define Camel routes using the Java DSL, XML & Kotlin.

Features

Fast startup & low RSS memory

Taking advantage of the build time and ahead-of-time compilation (AOT) tricks that Quarkus gives us, much of the Camel application can be pre-configured at build time resulting in fast startup times.

Application generator

Camel Quarkus is part of the wider Quarkus universe and thus its component extensions are available to select from code.quarkus.io.

Native executable support

Quarkus provides the means to build native executables with GraalVM. Camel Quarkus extensions provide all of the necessary plumbing that enable Camel components to work well natively.

Highly configurable

All of the important aspects of a Camel Quarkus application can be set up programatically with CDI or via configuration properties. By default, a CamelContext is configured and automatically started for you.

Check out the bootstrap & configuration guide for more information on the different ways to bootstrap & configure an application.

Some extensions can automagically configure various aspects of Camel for you (a bit like Spring Boot auto configuration). For example, the MongoDB extension ensures a Mongo client bean is added to the registry for the Mongo component to use.

Integrates with existing Quarkus extensions

Quarkus provides extensions for libraries and frameworks that are used by some camel components, so it makes sense to reuse these and inherit the native support and configuration options.

Observability

Health & liveness checks

Health & liveness checks can be configured via the Camel Health API or via Quarkus MicroProfile Health.

All configured checks are available on the standard MicroProfile Health endpoint URLs:

http://localhost:8080/health

http://localhost:8080/health/live

http://localhost:8080/health/ready

There's an example project which demonstrates health checks:

https://github.com/apache/camel-quarkus/tree/master/examples/health

Metrics

Camel provides a MicroProfile Metrics component which is used to integrate with Quarkus MicroProfile Metrics. Some basic Camel metrics are provided for you out of the box, and these can be supplemented by configuring additional metrics in your routes.

Metrics are available on the standard MicroProfile metrics endpoint:

http://localhost:8080/metrics

Tracing

Camel Quarkus integrates with the Quarkus OpenTracing extension. All you need to do is set up the required configuration properties and an OpenTracingTracer will get automatically added to the registry for Camel to use.

There's an example project demonstrating the above features here:

https://github.com/apache/camel-quarkus/tree/master/examples/observability

What if there's no extension for my favourite Camel component?

Fear not! Most Camel components if added manually to your project should run without any issues in JVM mode. However, some components may not work out of the box in native mode. In this case, feel free to raise an issue requesting an extension for the camel component.

If you're feeling brave, why not take a stab at creating the extension and provide a pull request. The Camel Quarkus contributors guide outlines the process for creating extensions.

Example

Here's a very basic example of quickly bootstrapping a Camel Quarkus application that uses the timer and log component extensions. We'll also use Camel Main as our preferred bootstrap method.

First generate the project skeleton. We'll use Maven, but you could also use code.quarkus.io.

mvn io.quarkus:quarkus-maven-plugin:1.7.0.Final:create \
    -DprojectGroupId=org.test \
    -DprojectArtifactId=timer-to-log-test \
    -DprojectVersion=1.0-SNAPSHOT \
    -Dextensions=camel-quarkus-timer,camel-quarkus-log,camel-quarkus-main

This creates a new project in the directory timer-to-log-test. In the generated pom.xml you'll see that the requested Camel component extensions have been added:

<dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-log</artifactId>
</dependency>
<dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-main</artifactId>
</dependency>
<dependency>
    <groupId>org.apache.camel.quarkus</groupId>
    <artifactId>camel-quarkus-timer</artifactId>
</dependency>

Next we'll add a simple route that prints a log message generated from a timer endpoint:

public class TimerToLogRoute extends RouteBuilder() {

    @Override
    public void configure() throws Exception {
        from("timer:test?period={% raw %}{{timer.period}}{% endraw %}")
            .setBody().constant("Camel Quarkus Rocks!")
            .to("log:example");
    }
}

Notice we used a placeholder value for the period on the timer endpoint. To demonstrate integration with Quarkus configuration, lets add an option to src/main/resources/application.properties. We'll also add some configuration for the log component:

timer.period=5000

camel.component.log.exchange-formatter = #class:org.apache.camel.support.processor.DefaultExchangeFormatter
camel.component.log.exchange-formatter.show-all = true

Development mode

To run the application in development mode do:

mvn quarkus:dev

Every 5 seconds you'll see a log message output to the console:

INFO  [example] (Camel (camel-3) thread #0 - timer://test) Exchange[ExchangePattern: InOnly, BodyType: String, Body: Camel Quarkus Rocks!]

To demonstrate the hot reload feature of Quarkus, adjust the exchange body like:

.setBody().constant("Camel Quarkus Rocks Again!")

Save the changes & the application will reload and print the new message.

INFO  [example] (Camel (camel-3) thread #0 - timer://test) Exchange[ExchangePattern: InOnly, BodyType: String, Body: Camel Quarkus Rocks Again!]

Native executable

Before generating a native executable for the application, make sure you have fulfilled the prerequisites outlined in the Quarkus documentation. Then do:

mvn package -Dnative

When the process has finished you can run:

target/timer-to-log-test-1.0-SNAPSHOT-runner

Next steps

We only scratched the surface of what's possible with Camel Quarkus. Some other topics to explore and experiment with are:

Conclusion

Hopefully that was a nice overview of what Camel Quarkus has to offer. More component extensions & features will be added in future releases.

If you have feedback or you'd like to contribute, check out the contributors guide:

https://camel.apache.org/camel-quarkus/latest/contributor-guide/index.html

The source code is available on GitHub:

https://github.com/apache/camel-quarkus

The Camel Quarkus team is on Zulip for chat:

https://camel.zulipchat.com

We also lurk in the Quarkus Zulip room:

https://quarkusio.zulipchat.com

There's also the Camel mailing lists:

https://camel.apache.org/manual/latest/mailing-lists.html

Happy coding!