Bootstrap and configuration

Camel Quarkus automatically configures and deploys a Camel Context bean which by default is started/stopped according to the Quarkus Application lifecycle. The configuration step happens at build time during Quarkus' augmentation phase and it is driven by the Camel Quarkus extensions which can be tuned using Camel Quarkus specific camel.quarkus.* properties. After the configuration is done, a minimal Camel Runtime is assembled and started at RUNTIME_INIT time.


The CDI APIs can be used to configure various aspects of Camel behavior. For example, to configure the LogComponent you can write a code like:

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Named;

import org.apache.camel.component.log.LogComponent;

public class Configurations {
     * Produces a {@link LogComponent} instance with a custom exchange formatter set-up.
    @Named (1)
    LogComponent log() {
        DefaultExchangeFormatter formatter = new DefaultExchangeFormatter();

        LogComponent component = new LogComponent();

        return component;
1 Camel uses the component URI scheme to look-up components from its registry, this requires you to add the @Named annotation to the method, otherwise the CDI container would create an anonymous bean and Camel would not be able to look it up.

In Camel Quarkus the Camel components are discovered during the augmentation phase, producing a new component as shown in the example above would invalidate any optimization that may have been made.

As a better alternative you can use @Inject to obtain an instance of a component automatically created by Camel or you can observe one of the events fired by Camel Quarkus as shown in the following example, in which we use @Observes to be notified about components added to the Camel Context:

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
import org.apache.camel.component.log.LogComponent;

public static class EventHandler {
    public void onComponentAdd(@Observes ComponentAddEvent event) {
        if (event.getComponent() instanceof LogComponent) {
            // do something with the log component

Camel Main

To configure components and other aspects of Apache Camel through properties, you can add the camel-quarkus-main extension which brings functionalities from Apache Camel Main to Camel Quarkus.

In the example below, we apply the same configuration as the one from the Java example above by using properties: = = false = false

In addition to support configuring Camel through properties, camel-quarkus-main allows you to use conventions to configure the Camel behavior. For example, if there is a single ExchangeFormatter instance in the CDI container, then it will automatically wire that bean to the LogComponent.

Camel Main also brings the option to write Quarkus Command Mode Applications with control about when the Camel runtime should start:

import io.quarkus.runtime.Quarkus;
import io.quarkus.runtime.annotations.QuarkusMain;
import org.apache.camel.quarkus.main.CamelMainApplication;

public class Main {
    public static void main(String... args) {
        // your logic here
        //, args); (1)
1 Start Quarkus and the Camel Quarkus runtime

It is recommended to perform very little logic in the Java Main.

Find more details about Camel Quarkus command line applications in this blog post.

XML Configuration

In order to configure Camel routes, rests or templates in XML, you must add a Camel XML parser dependency to the classpath. E.g either camel-quarkus-xml-io or camel-quarkus-xml-jaxb. camel-quarkus-xml-io is preferred due to its lightweight implementation.

With Camel Main, you can set a property that points to the location of resources XML files such as routes, REST DSL and Route templates:

camel.main.routes-include-pattern = routes/routes.xml, file:src/main/routes/rests.xml, file:src/main/rests/route-template.xml

Path globbing like camel.main.routes-include-pattern = *./routes.xml currently does not work in native mode.

<routes xmlns:xsi=""

    <route id="xml-route">
        <from uri="timer:from-xml?period=1000"/>
        <log message="Hello XML!"/>


Spring XML with <beans> or Blueprint XML with <blueprint> elements are not supported. The route XML should be in the simplified version like:

Rest DSL
<rests xmlns="">
	<rest id="greeting" path="/greeting">
	    <get uri="/hello">
                <constant>Hello World!</constant>
Route Templates
<routeTemplates xmlns="">
    <routeTemplate id="myTemplate">
        <templateParameter name="name"/>
        <templateParameter name="greeting"/>
        <templateParameter name="myPeriod" defaultValue="3s"/>
            <from uri="timer:{{name}}?period={{myPeriod}}"/>
            <setBody><simple>{{greeting}} ${body}</simple></setBody>
            <log message="${body}"/>