Spring Boot

Spring Boot component provides auto-configuration for Apache Camel. Our opinionated auto-configuration of the Camel context auto-detects Camel routes available in the Spring context and registers the key Camel utilities (like producer template, consumer template and the type converter) as beans.

Maven users will need to add the following dependency to their pom.xml in order to use this component:

<dependency>
    <groupId>org.apache.camel.springboot</groupId>
    <artifactId>camel-spring-boot</artifactId>
    <version>${camel.version}</version> <!-- use the same version as your Camel core version -->
</dependency>

camel-spring-boot jar comes with the spring.factories file, so as soon as you add that dependency into your classpath, Spring Boot will automatically auto-configure Camel for you.

Camel Spring Boot Starter

Apache Camel ships a Spring Boot Starter module that allows you to develop Spring Boot applications using starters. There is a sample application in the source code also.

To use the starter, add the following to your spring boot pom.xml file:

<dependency>
    <groupId>org.apache.camel.springboot</groupId>
    <artifactId>camel-spring-boot-bom</artifactId>
    <version>${camel.version}</version> <!-- use the same version as your Camel core version -->
</dependency>

Then you can just add classes with your Camel routes such as:

package com.example;

import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;

@Component
public class MyRoute extends RouteBuilder {

    @Override
    public void configure() throws Exception {
        from("timer:foo").to("log:bar");
    }
}

Then these routes will be started automatically.

You can customize the Camel application in the application.properties or application.yml file.

Spring Boot Auto-Configuration

When using spring-boot with Spring Boot make sure to use the following Maven dependency to have support for auto configuration:

<dependency>
  <groupId>org.apache.camel.springboot</groupId>
  <artifactId>camel-spring-boot-starter</artifactId>
  <version>x.x.x</version>
  <!-- use the same version as your Camel core version -->
</dependency>

The component supports 199 options, which are listed below.

Name Description Default Type

camel.cloud.enabled

Global option to enable/disable Camel cloud support, default is true.

true

Boolean

camel.cloud.load-balancer.enabled

Global option to enable/disable Camel cloud load balancer, default is true.

true

Boolean

camel.cloud.service-call.component

The Camel component to use for calling the service. The default is http component.

String

camel.cloud.service-call.default-load-balancer

Determine if the default load balancer should be used instead of any auto discovered one.

false

Boolean

camel.cloud.service-call.expression

The expression to use.

String

camel.cloud.service-call.expression-language

The expression language to use, default is ref.

ref

String

camel.cloud.service-call.load-balancer

A reference to the org.apache.camel.cloud.ServiceLoadBalancer to use.

String

camel.cloud.service-call.service-chooser

A reference to the org.apache.camel.cloud.ServiceChooser to use.

String

camel.cloud.service-call.service-discovery

A reference to the org.apache.camel.cloud.ServiceDiscovery to use.

String

camel.cloud.service-call.service-filter

A reference to the org.apache.camel.cloud.ServiceFilter to use.

String

camel.cloud.service-call.uri

The uri of the endpoint to send to. The uri can be dynamic computed using the simple language expression.

String

camel.cloud.service-chooser.enabled

Global option to enable/disable Camel cloud service chooser, default is true.

true

Boolean

camel.cloud.service-discovery.configurations

Configure the service discovery rules.

Map

camel.cloud.service-discovery.enabled

Global option to enable/disable Camel cloud service discovery, default is true.

true

Boolean

camel.cloud.service-discovery.service-definitions

Configure static service discovery with distinct id, host, port, and metadata properties.

Map

camel.cloud.service-discovery.services

Configure static service discovery using simple host:port strings.

Map

camel.cloud.service-filter.blacklist

Configure service filter blacklists.

Map

camel.cloud.service-filter.configurations

Configure the service filtering rules.

Map

camel.cloud.service-filter.enabled

Global option to enable/disable Camel cloud service filter, default is true.

true

Boolean

camel.cloud.service-registry.enabled

Configure if service registry should be enabled or not, default true.

true

Boolean

camel.cloud.service-registry.service-host

Configure the service listening address.

String

camel.clustered.controller.cluster-service

The cluster service.

CamelClusterService

camel.clustered.controller.enabled

Global option to enable/disable Camel clustered route controller, default is false.

false

Boolean

camel.clustered.controller.initial-delay

Set the amount of time (in millis) the route controller should wait before to start the routes after the camel context is started or after the route is initialized if the route is created after the camel context is started.

String

camel.clustered.controller.namespace

The default namespace.

String

camel.clustered.controller.routes

Routes configuration.

Map

camel.component.enabled

Global option to enable/disable component auto-configuration, default is true.

true

Boolean

camel.component.properties.auto-discover-properties-sources

Whether to automatically discovery instances of PropertiesSource from registry and service factory.

true

Boolean

camel.component.properties.default-fallback-enabled

If false, the component does not attempt to find a default for the key by looking after the colon separator.

true

Boolean

camel.component.properties.encoding

Encoding to use when loading properties file from the file system or classpath. If no encoding has been set, then the properties files is loaded using ISO-8859-1 encoding (latin-1) as documented by java.util.Properties#load(java.io.InputStream).

String

camel.component.properties.environment-variable-mode

Sets the OS environment variables mode (0 = never, 1 = fallback, 2 = override). The default mode (override) is to use OS environment variables if present, and override any existing properties. OS environment variable mode is checked before JVM system property mode.

2

Integer

camel.component.properties.ignore-missing-location

Whether to silently ignore if a location cannot be located, such as a properties file not found.

false

Boolean

camel.component.properties.initial-properties

Sets initial properties which will be used before any locations are resolved. The option is a java.util.Properties type.

String

camel.component.properties.location

A list of locations to load properties. You can use comma to separate multiple locations. This option will override any default locations and only use the locations from this option.

String

camel.component.properties.override-properties

Sets a special list of override properties that take precedence and will use first, if a property exist. The option is a java.util.Properties type.

String

camel.component.properties.properties-parser

To use a custom PropertiesParser. The option is a org.apache.camel.component.properties.PropertiesParser type.

String

camel.component.properties.system-properties-mode

Sets the JVM system property mode (0 = never, 1 = fallback, 2 = override). The default mode (override) is to use system properties if present, and override any existing properties. OS environment variable mode is checked before JVM system property mode.

2

Integer

camel.dataformat.enabled

Global option to enable/disable dataformat auto-configuration, default is true.

true

Boolean

camel.health.consumers-enabled

Whether consumers health check is enabled. <p> Is default enabled.

Boolean

camel.health.enabled

Whether health check is enabled globally. <p> Is default enabled.

Boolean

camel.health.exclude-pattern

Pattern to exclude health checks from being invoked by Camel when checking healths. Multiple patterns can be separated by comma.

String

camel.health.exposure-level

Sets the level of details to exposure as result of invoking health checks. There are the following levels: full, default, oneline The full level will include all details and status from all the invoked health checks. The default level will report UP if everything is okay, and only include detailed information for health checks that was DOWN. The oneline level will only report either UP or DOWN.

default

String

camel.health.initial-state

The initial state of health-checks (readiness). There are the following states: UP, DOWN, UNKNOWN. By default, the state is DOWN, is regarded as being pessimistic/careful. This means that the overall health checks may report as DOWN during startup and then only if everything is up and running flip to being UP. Setting the initial state to UP, is regarded as being optimistic. This means that the overall health checks may report as UP during startup and then if a consumer or other service is in fact un-healthy, then the health-checks can flip being DOWN. Setting the state to UNKNOWN means that some health-check would be reported in unknown state, especially during early bootstrap where a consumer may not be fully initialized or validated a connection to a remote system. This option allows to pre-configure the state for different modes.

down

String

camel.health.registry-enabled

Whether registry health check is enabled. <p> Is default enabled.

Boolean

camel.health.routes-enabled

Whether routes health check is enabled. <p> Is default enabled.

Boolean

camel.language.enabled

Global option to enable/disable language auto-configuration, default is true.

true

Boolean

camel.routetemplate.config

Route template configurations.

List

camel.springboot.allow-use-original-message

Sets whether to allow access to the original message from Camel’s error handler, or from org.apache.camel.spi.UnitOfWork.getOriginalInMessage(). Turning this off can optimize performance, as defensive copy of the original message is not needed. Default is false.

false

Boolean

camel.springboot.auto-startup

Sets whether the object should automatically start when Camel starts. Important: Currently only routes can be disabled, as CamelContext’s are always started. Note: When setting auto startup false on CamelContext then that takes precedence and no routes is started. You would need to start CamelContext explicit using the org.apache.camel.CamelContext.start() method, to start the context, and then you would need to start the routes manually using Camelcontext.getRouteController().startRoute(String). Default is true to always start up.

true

Boolean

camel.springboot.autowired-enabled

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc. Default is true.

true

Boolean

camel.springboot.backlog-tracing

Sets whether backlog tracing is enabled or not. Default is false.

false

Boolean

camel.springboot.bean-introspection-extended-statistics

Sets whether bean introspection uses extended statistics. The default is false.

false

Boolean

camel.springboot.bean-introspection-logging-level

Sets the logging level used by bean introspection, logging activity of its usage. The default is TRACE.

LoggingLevel

camel.springboot.bean-post-processor-enabled

Can be used to turn off bean post processing. Be careful to turn this off, as this means that beans that use Camel annotations such as org.apache.camel.EndpointInject, org.apache.camel.ProducerTemplate, org.apache.camel.Produce, org.apache.camel.Consume etc will not be injected and in use. Turning this off should only be done if you are sure you do not use any of these Camel features. Not all runtimes allow turning this off (such as camel-blueprint or camel-cdi with XML). The default value is true (enabled).

true

Boolean

camel.springboot.camel-events-timestamp-enabled

Whether to include timestamps for all emitted Camel Events. Enabling this allows to know fine-grained at what time each event was emitted, which can be used for reporting to report exactly the time of the events. This is by default false to avoid the overhead of including this information.

false

Boolean

camel.springboot.case-insensitive-headers

Whether to use case sensitive or insensitive headers. Important: When using case sensitive (this is set to false). Then the map is case sensitive which means headers such as content-type and Content-Type are two different keys which can be a problem for some protocols such as HTTP based, which rely on case insensitive headers. However case sensitive implementations can yield faster performance. Therefore use case sensitive implementation with care. Default is true.

true

Boolean

camel.springboot.consumer-template-cache-size

Consumer template endpoints cache size.

1000

Integer

camel.springboot.debugging

Sets whether debugging is enabled or not. Default is false.

false

Boolean

camel.springboot.dev-console-enabled

Whether to enable developer console (requires camel-console on classpath). The developer console is only for assisting during development. This is NOT for production usage.

false

Boolean

camel.springboot.dump-routes

If dumping is enabled then Camel will during startup dump all loaded routes (incl rests and route templates) represented as XML DSL into the log. This is intended for trouble shooting or to assist during development. Sensitive information that may be configured in the route endpoints could potentially be included in the dump output and is therefore not recommended to be used for production usage. This requires to have camel-xml-jaxb on the classpath to be able to dump the routes as XML.

false

Boolean

camel.springboot.duration-max-action

Controls whether the Camel application should shutdown the JVM, or stop all routes, when duration max is triggered.

shutdown

String

camel.springboot.duration-max-idle-seconds

To specify for how long time in seconds Camel can be idle before automatic terminating the JVM. You can use this to run Spring Boot for a short while.

0

Integer

camel.springboot.duration-max-messages

To specify how many messages to process by Camel before automatic terminating the JVM. You can use this to run Spring Boot for a short while.

0

Integer

camel.springboot.duration-max-seconds

To specify for how long time in seconds to keep running the JVM before automatic terminating the JVM. You can use this to run Spring Boot for a short while.

0

Integer

camel.springboot.eager-classloading

Whether to eager load a common set of Camel classes that would otherwise first be loaded on processing the first message. By eager loading these classes then the JVM has already loaded the classes during build phase, which allows Camel to process the first message faster.

false

Boolean

camel.springboot.endpoint-bridge-error-handler

Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions occurred while the consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. <p/> By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN/ERROR level and ignored. The default value is false.

false

Boolean

camel.springboot.endpoint-lazy-start-producer

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing. The default value is false.

false

Boolean

camel.springboot.endpoint-runtime-statistics-enabled

Sets whether endpoint runtime statistics is enabled (gathers runtime usage of each incoming and outgoing endpoints). The default value is false.

false

Boolean

camel.springboot.exchange-factory

Controls whether to pool (reuse) exchanges or create new exchanges (prototype). Using pooled will reduce JVM garbage collection overhead by avoiding to re-create Exchange instances per message each consumer receives. The default is prototype mode.

default

String

camel.springboot.exchange-factory-capacity

The capacity the pool (for each consumer) uses for storing exchanges. The default capacity is 100.

100

Integer

camel.springboot.exchange-factory-statistics-enabled

Configures whether statistics is enabled on exchange factory.

false

Boolean

camel.springboot.file-configurations

Directory to load additional configuration files that contains configuration values that takes precedence over any other configuration. This can be used to refer to files that may have secret configuration that has been mounted on the file system for containers. You must use either file: or classpath: as prefix to load from file system or classpath. Then you can specify a pattern to load from sub directories and a name pattern such as file:/var/app/secret/*.properties.

String

camel.springboot.global-options

Sets global options that can be referenced in the camel context Important: This has nothing to do with property placeholders, and is just a plain set of key/value pairs which are used to configure global options on CamelContext, such as a maximum debug logging length etc.

Map

camel.springboot.include-non-singletons

Whether to include non-singleton beans (prototypes) when scanning for RouteBuilder instances. By default only singleton beans is included in the context scan.

false

Boolean

camel.springboot.inflight-repository-browse-enabled

Sets whether the inflight repository should allow browsing each inflight exchange. This is by default disabled as there is a very slight performance overhead when enabled.

false

Boolean

camel.springboot.java-routes-exclude-pattern

Used for exclusive filtering RouteBuilder classes which are collected from the registry or via classpath scanning. The exclusive filtering takes precedence over inclusive filtering. The pattern is using Ant-path style pattern. Multiple patterns can be specified separated by comma. For example to exclude all classes starting with Bar use: **/Bar* To exclude all routes form a specific package use: com/mycompany/bar/* To exclude all routes form a specific package and its sub-packages use double wildcards: com/mycompany/bar/** And to exclude all routes from two specific packages use: com/mycompany/bar/*,com/mycompany/stuff/*.

String

camel.springboot.java-routes-include-pattern

Used for inclusive filtering RouteBuilder classes which are collected from the registry or via classpath scanning. The exclusive filtering takes precedence over inclusive filtering. The pattern is using Ant-path style pattern. Multiple patterns can be specified separated by comma. Multiple patterns can be specified separated by comma. For example to include all classes starting with Foo use: **/Foo* To include all routes form a specific package use: com/mycompany/foo/* To include all routes form a specific package and its sub-packages use double wildcards: com/mycompany/foo/** And to include all routes from two specific packages use: com/mycompany/foo/*,com/mycompany/stuff/*.

String

camel.springboot.jmx-enabled

Enable JMX in your Camel application.

true

Boolean

camel.springboot.jmx-management-m-beans-level

Sets the JMX statistics level The level can be set to Extended to gather additional information The default value is Default.

ManagementMBeansLevel

camel.springboot.jmx-management-name-pattern

The naming pattern for creating the CamelContext JMX management name. The default pattern is name.

name

String

camel.springboot.jmx-management-statistics-level

Sets the JMX statistics level The level can be set to Extended to gather additional information The default value is Default.

ManagementStatisticsLevel

camel.springboot.lightweight

Experimental: Configure the context to be lightweight. This will trigger some optimizations and memory reduction options. Lightweight context has some limitations. At this moment, dynamic endpoint destinations are not supported.

false

Boolean

camel.springboot.load-health-checks

Whether to load custom health checks by scanning classpath.

false

Boolean

camel.springboot.load-type-converters

Whether to load custom type converters by scanning classpath. This is used for backwards compatibility with Camel 2.x. Its recommended to migrate to use fast type converter loading by setting <tt>@Converter(generateLoader = true)</tt> on your custom type converter classes.

true

Boolean

camel.springboot.log-debug-max-chars

Is used to limit the maximum length of the logging Camel message bodies. If the message body is longer than the limit, the log message is clipped. Use -1 to have unlimited length. Use for example 1000 to log at most 1000 characters.

0

Integer

camel.springboot.log-exhausted-message-body

Sets whether to log exhausted message body with message history. Default is false.

false

Boolean

camel.springboot.log-mask

Sets whether log mask is enabled or not. Default is false.

false

Boolean

camel.springboot.main-run-controller

Whether to use the main run controller to ensure the Spring-Boot application keeps running until being stopped or the JVM terminated. You typically only need this if you run Spring-Boot standalone. If you run Spring-Boot with spring-boot-starter-web then the web container keeps the JVM running.

false

Boolean

camel.springboot.mdc-logging-keys-pattern

Sets the pattern used for determining which custom MDC keys to propagate during message routing when the routing engine continues routing asynchronously for the given message. Setting this pattern to * will propagate all custom keys. Or setting the pattern to foo*,bar* will propagate any keys starting with either foo or bar. Notice that a set of standard Camel MDC keys are always propagated which starts with camel. as key name. The match rules are applied in this order (case insensitive): 1. exact match, returns true 2. wildcard match (pattern ends with a * and the name starts with the pattern), returns true 3. regular expression match, returns true 4. otherwise returns false.

String

camel.springboot.message-history

Sets whether message history is enabled or not. Default is true.

true

Boolean

camel.springboot.modeline

Whether camel-k style modeline is also enabled when not using camel-k. Enabling this allows to use a camel-k like experience by being able to configure various settings using modeline directly in your route source code.

false

Boolean

camel.springboot.name

Sets the name of the CamelContext.

String

camel.springboot.producer-template-cache-size

Producer template endpoints cache size.

1000

Integer

camel.springboot.route-controller-back-off-delay

Backoff delay in millis when restarting a route that failed to startup.

2000

Long

camel.springboot.route-controller-back-off-max-attempts

Backoff maximum number of attempts to restart a route that failed to startup. When this threshold has been exceeded then the controller will give up attempting to restart the route, and the route will remain as stopped.

0

Long

camel.springboot.route-controller-back-off-max-delay

Backoff maximum delay in millis when restarting a route that failed to startup.

0

Long

camel.springboot.route-controller-back-off-max-elapsed-time

Backoff maximum elapsed time in millis, after which the backoff should be considered exhausted and no more attempts should be made.

0

Long

camel.springboot.route-controller-back-off-multiplier

Backoff multiplier to use for exponential backoff. This is used to extend the delay between restart attempts.

1

Double

camel.springboot.route-controller-exclude-routes

Pattern for filtering routes to be included as supervised. The pattern is matching on route id, and endpoint uri for the route. Multiple patterns can be separated by comma. For example to include all kafka routes, you can say <tt>kafka:*</tt>. And to include routes with specific route ids <tt>myRoute,myOtherRoute</tt>. The pattern supports wildcards and uses the matcher from org.apache.camel.support.PatternHelper#matchPattern.

String

camel.springboot.route-controller-include-routes

Pattern for filtering routes to be excluded as supervised. The pattern is matching on route id, and endpoint uri for the route. Multiple patterns can be separated by comma. For example to exclude all JMS routes, you can say <tt>jms:*</tt>. And to exclude routes with specific route ids <tt>mySpecialRoute,myOtherSpecialRoute</tt>. The pattern supports wildcards and uses the matcher from org.apache.camel.support.PatternHelper#matchPattern.

String

camel.springboot.route-controller-initial-delay

Initial delay in milli seconds before the route controller starts, after CamelContext has been started.

0

Long

camel.springboot.route-controller-supervise-enabled

To enable using supervising route controller which allows Camel to startup and then the controller takes care of starting the routes in a safe manner. This can be used when you want to startup Camel despite a route may otherwise fail fast during startup and cause Camel to fail to startup as well. By delegating the route startup to the supervising route controller then it manages the startup using a background thread. The controller allows to be configured with various settings to attempt to restart failing routes.

false

Boolean

camel.springboot.route-controller-thread-pool-size

The number of threads used by the route controller scheduled thread pool that are used for restarting routes. The pool uses 1 thread by default, but you can increase this to allow the controller to concurrently attempt to restart multiple routes in case more than one route has problems starting.

1

Integer

camel.springboot.route-controller-unhealthy-on-exhausted

Whether to mark the route as unhealthy (down) when all restarting attempts (backoff) have failed and the route is not successfully started and the route manager is giving up. Setting this to true allows health checks to know about this and can report the Camel application as DOWN. The default is false.

false

Boolean

camel.springboot.route-filter-exclude-pattern

Used for filtering routes matching the given pattern, which follows the following rules: - Match by route id - Match by route input endpoint uri The matching is using exact match, by wildcard and regular expression. For example to only include routes which starts with foo in their route id’s, use: include=foo* And to exclude routes which starts from JMS endpoints, use: exclude=jms:* Multiple patterns can be separated by comma, for example to exclude both foo and bar routes, use: exclude=foo*,bar* Exclude takes precedence over include.

String

camel.springboot.route-filter-include-pattern

Used for filtering routes matching the given pattern, which follows the following rules: - Match by route id - Match by route input endpoint uri The matching is using exact match, by wildcard and regular expression. For example to only include routes which starts with foo in their route id’s, use: include=foo* And to exclude routes which starts from JMS endpoints, use: exclude=jms:* Multiple patterns can be separated by comma, for example to exclude both foo and bar routes, use: exclude=foo*,bar* Exclude takes precedence over include.

String

camel.springboot.routes-collector-enabled

Whether the routes collector is enabled or not. When enabled Camel will auto-discover routes (RouteBuilder instances from the registry and also load additional routes from the file system). The routes collector is default enabled.

true

Boolean

camel.springboot.routes-exclude-pattern

Used for exclusive filtering of routes from directories. The exclusive filtering takes precedence over inclusive filtering. The pattern is using Ant-path style pattern. Multiple patterns can be specified separated by comma, as example, to exclude all the routes from a directory whose name contains foo use: **/foo.

String

camel.springboot.routes-include-pattern

Used for inclusive filtering of routes from directories. The exclusive filtering takes precedence over inclusive filtering. The pattern is using Ant-path style pattern. Multiple patterns can be specified separated by comma, as example, to include all the routes from a directory whose name contains foo use: **/foo.

classpath:camel/,classpath:camel-template/,classpath:camel-rest/*

String

camel.springboot.routes-reload-directory

Directory to scan (incl subdirectories) for route changes. Camel cannot scan the classpath, so this must be configured to a file directory. Development with Maven as build tool, you can configure the directory to be src/main/resources to scan for Camel routes in XML or YAML files.

src/main/resources

String

camel.springboot.routes-reload-directory-recursive

Whether the directory to scan should include sub directories. Depending on the number of sub directories, then this can cause the JVM to startup slower as Camel uses the JDK file-watch service to scan for file changes.

false

Boolean

camel.springboot.routes-reload-enabled

Used for enabling automatic routes reloading. If enabled then Camel will watch for file changes in the given reload directory, and trigger reloading routes if files are changed.

false

Boolean

camel.springboot.routes-reload-pattern

Used for inclusive filtering of routes from directories. Typical used for specifying to accept routes in XML or YAML files. Multiple patterns can be specified separated by comma.

camel/*

String

camel.springboot.routes-reload-remove-all-routes

When reloading routes should all existing routes be stopped and removed. By default, Camel will stop and remove all existing routes before reloading routes. This ensures that only the reloaded routes will be active. If disabled then only routes with the same route id is updated, and any existing routes are continued to run.

true

Boolean

camel.springboot.routes-reload-restart-duration

Whether to restart max duration when routes are reloaded. For example if max duration is 60 seconds, and a route is reloaded after 25 seconds, then this will restart the count and wait 60 seconds again.

true

Boolean

camel.springboot.shutdown-log-inflight-exchanges-on-timeout

Sets whether to log information about the inflight Exchanges which are still running during a shutdown which didn’t complete without the given timeout. This requires to enable the option inflightRepositoryExchangeEnabled.

true

Boolean

camel.springboot.shutdown-now-on-timeout

Sets whether to force shutdown of all consumers when a timeout occurred and thus not all consumers was shutdown within that period. You should have good reasons to set this option to false as it means that the routes keep running and is halted abruptly when CamelContext has been shutdown.

true

Boolean

camel.springboot.shutdown-routes-in-reverse-order

Sets whether routes should be shutdown in reverse or the same order as they where started.

true

Boolean

camel.springboot.shutdown-suppress-logging-on-timeout

Whether Camel should try to suppress logging during shutdown and timeout was triggered, meaning forced shutdown is happening. And during forced shutdown we want to avoid logging errors/warnings et all in the logs as a side-effect of the forced timeout. Notice the suppress is a best effort as there may still be some logs coming from 3rd party libraries and whatnot, which Camel cannot control. This option is default false.

false

Boolean

camel.springboot.shutdown-timeout

Timeout in seconds to graceful shutdown Camel.

300

Integer

camel.springboot.source-location-enabled

Whether to capture precise source location:line-number for all EIPs in Camel routes. Enabling this will impact parsing Java based routes (also Groovy, Kotlin, etc.) on startup as this uses JDK StackTraceElement to calculate the location from the Camel route, which comes with a performance cost. This only impact startup, not the performance of the routes at runtime.

false

Boolean

camel.springboot.startup-recorder

To use startup recorder for capturing execution time during starting Camel. The recorder can be one of: false (or off), logging, java-flight-recorder (or jfr).

String

camel.springboot.startup-recorder-dir

Directory to store the recording. By default the user home directory will be used. Use false to turn off saving recording to disk.

String

camel.springboot.startup-recorder-duration

How long time to run the startup recorder. Use 0 (default) to keep the recorder running until the JVM is exited. Use -1 to stop the recorder right after Camel has been started (to only focus on potential Camel startup performance bottlenecks) Use a positive value to keep recording for N seconds. When the recorder is stopped then the recording is auto saved to disk (note: save to disk can be disabled by setting startupRecorderDir to false).

0

Long

camel.springboot.startup-recorder-max-depth

To filter our sub steps at a maximum depth. Use -1 for no maximum. Use 0 for no sub steps. Use 1 for max 1 sub step, and so forth. The default is -1.

-1

Integer

camel.springboot.startup-recorder-profile

To use a specific Java Flight Recorder profile configuration, such as default or profile. The default is default.

default

String

camel.springboot.startup-recorder-recording

To enable Java Flight Recorder to start a recording and automatic dump the recording to disk after startup is complete. This requires that camel-jfr is on the classpath, and to enable this option.

false

Boolean

camel.springboot.startup-summary-level

Controls the level of information logged during startup (and shutdown) of CamelContext.

StartupSummaryLevel

camel.springboot.stream-caching-any-spool-rules

Sets whether if just any of the org.apache.camel.spi.StreamCachingStrategy.SpoolRule rules returns true then shouldSpoolCache(long) returns true, to allow spooling to disk. If this option is false, then all the org.apache.camel.spi.StreamCachingStrategy.SpoolRule must return true. The default value is false which means that all the rules must return true.

false

Boolean

camel.springboot.stream-caching-buffer-size

Sets the stream caching buffer size to use when allocating in-memory buffers used for in-memory stream caches. The default size is 4096.

0

Integer

camel.springboot.stream-caching-enabled

Sets whether stream caching is enabled or not. While stream types (like StreamSource, InputStream and Reader) are commonly used in messaging for performance reasons, they also have an important drawback: they can only be read once. In order to be able to work with message content multiple times, the stream needs to be cached. Streams are cached in memory only (by default). If streamCachingSpoolEnabled=true, then, for large stream messages (over 128 KB by default) will be cached in a temporary file instead, and Camel will handle deleting the temporary file once the cached stream is no longer necessary. Default is true.

true

Boolean

camel.springboot.stream-caching-remove-spool-directory-when-stopping

Whether to remove stream caching temporary directory when stopping. This option is default true.

true

Boolean

camel.springboot.stream-caching-spool-cipher

Sets a stream caching cipher name to use when spooling to disk to write with encryption. By default the data is not encrypted.

String

camel.springboot.stream-caching-spool-directory

Sets the stream caching spool (temporary) directory to use for overflow and spooling to disk. If no spool directory has been explicit configured, then a temporary directory is created in the java.io.tmpdir directory.

String

camel.springboot.stream-caching-spool-enabled

To enable stream caching spooling to disk. This means, for large stream messages (over 128 KB by default) will be cached in a temporary file instead, and Camel will handle deleting the temporary file once the cached stream is no longer necessary. Default is false.

false

Boolean

camel.springboot.stream-caching-spool-threshold

Stream caching threshold in bytes when overflow to disk is activated. The default threshold is 128kb. Use -1 to disable overflow to disk.

0

Long

camel.springboot.stream-caching-spool-used-heap-memory-limit

Sets what the upper bounds should be when streamCachingSpoolUsedHeapMemoryThreshold is in use.

String

camel.springboot.stream-caching-spool-used-heap-memory-threshold

Sets a percentage (1-99) of used heap memory threshold to activate stream caching spooling to disk.

0

Integer

camel.springboot.stream-caching-statistics-enabled

Sets whether stream caching statistics is enabled.

false

Boolean

camel.springboot.thread-name-pattern

Sets the thread name pattern used for creating the full thread name. The default pattern is: Camel (camelId) thread #counter - name Where camelId is the name of the CamelContext. and counter is a unique incrementing counter. and name is the regular thread name. You can also use longName which is the long thread name which can includes endpoint parameters etc.

String

camel.springboot.tracing

Sets whether tracing is enabled or not. Default is false.

false

Boolean

camel.springboot.tracing-logging-format

To use a custom tracing logging format. The default format (arrow, routeId, label) is: %-4.4s [%-12.12s] [%-33.33s].

String

camel.springboot.tracing-pattern

Tracing pattern to match which node EIPs to trace. For example to match all To EIP nodes, use to*. The pattern matches by node and route id’s Multiple patterns can be separated by comma.

String

camel.springboot.tracing-standby

Boolean

camel.springboot.use-breadcrumb

Set whether breadcrumb is enabled. The default value is false.

false

Boolean

camel.springboot.use-data-type

Whether to enable using data type on Camel messages. Data type are automatic turned on if one or more routes has been explicit configured with input and output types. Otherwise data type is default off.

false

Boolean

camel.springboot.use-mdc-logging

To turn on MDC logging.

false

Boolean

camel.springboot.uuid-generator

UUID generator to use. default (32 bytes), short (16 bytes), classic (32 bytes or longer), simple (long incrementing counter), off (turned off for exchanges - only intended for performance profiling).

default

String

camel.springboot.warn-on-early-shutdown

Whether to log a WARN if Camel on Spring Boot was immediately shutdown after starting which very likely is because there is no JVM thread to keep the application running.

true

Boolean

camel.ssl.cert-alias

An optional certificate alias to use. This is useful when the keystore has multiple certificates.

String

camel.ssl.cipher-suites

The optional explicitly configured cipher suites for this configuration.

CipherSuitesParameters

camel.ssl.cipher-suites-filter

The optional cipher suite filter configuration for this configuration.

FilterParameters

camel.ssl.client-parameters

The optional configuration options to be applied purely to the client side settings of the SSLContext. Settings specified here override any duplicate settings provided at the overall level by this class. These parameters apply to SSLSocketFactory and SSLEngine produced by the SSLContext produced from this class as well as to the SSLContext itself.

SSLContextClientParameters

camel.ssl.config

Global Camel security configuration.

SSLContextParameters

camel.ssl.key-managers

The optional key manager configuration for creating the KeyManager used in constructing an SSLContext.

KeyManagersParameters

camel.ssl.provider

The optional provider identifier for the JSSE implementation to use when constructing an SSLContext.

String

camel.ssl.secure-random

The optional secure random configuration options to use for constructing the SecureRandom used in the creation of an SSLContext.

SecureRandomParameters

camel.ssl.secure-socket-protocol

The optional protocol for the secure sockets created by the SSLContext represented by this instance’s configuration. See Appendix A in the Java Secure Socket Extension Reference Guide for information about standard protocol names.

String

camel.ssl.secure-socket-protocols

The optional explicitly configured secure socket protocol names for this configuration.

SecureSocketProtocolsParameters

camel.ssl.secure-socket-protocols-filter

The option secure socket protocol name filter configuration for this configuration.

FilterParameters

camel.ssl.server-parameters

The optional configuration options to be applied purely to the server side settings of the SSLContext. Settings specified here override any duplicate settings provided at the overall level by this class. These parameters apply to SSLServerSocketFactory and SSLEngine produced by the SSLContext produced from this class as well as to the SSLContext itself.

SSLContextServerParameters

camel.ssl.session-timeout

The optional SSLSessionContext timeout time for javax.net.ssl.SSLSession in seconds.

String

camel.ssl.trust-managers

The optional trust manager configuration for creating the TrustManager used in constructing an SSLContext.

TrustManagersParameters

camel.threadpool.allow-core-thread-time-out

Sets default whether to allow core threads to timeout.

Boolean

camel.threadpool.config

Adds a configuration for a specific thread pool profile (inherits default values).

Map

camel.threadpool.config.allow-core-thread-time-out

Sets whether to allow core threads to timeout.

Boolean

camel.threadpool.config.id

Sets the id of this thread pool.

String

camel.threadpool.config.keep-alive-time

Sets the keep alive time for inactive threads.

Long

camel.threadpool.config.max-pool-size

Sets the maximum pool size.

Integer

camel.threadpool.config.max-queue-size

Sets the maximum number of tasks in the work queue. Use -1 or an unbounded queue.

Integer

camel.threadpool.config.pool-size

Sets the core pool size (threads to keep minimum in pool).

Integer

camel.threadpool.config.rejected-policy

Sets the handler for tasks which cannot be executed by the thread pool.

ThreadPoolRejectedPolicy

camel.threadpool.config.time-unit

Sets the time unit used for keep alive time.

TimeUnit

camel.threadpool.keep-alive-time

Sets the default keep alive time for inactive threads.

Long

camel.threadpool.max-pool-size

Sets the default maximum pool size.

Integer

camel.threadpool.max-queue-size

Sets the default maximum number of tasks in the work queue. Use -1 or an unbounded queue.

Integer

camel.threadpool.pool-size

Sets the default core pool size (threads to keep minimum in pool).

Integer

camel.threadpool.rejected-policy

Sets the default handler for tasks which cannot be executed by the thread pool.

ThreadPoolRejectedPolicy

camel.threadpool.time-unit

Sets the default time unit used for keep alive time.

TimeUnit

camel.vault.aws.access-key

The AWS access key.

String

camel.vault.aws.default-credentials-provider

Define if we want to use the AWS Default Credentials Provider or not.

false

Boolean

camel.vault.aws.region

The AWS region.

String

camel.vault.aws.secret-key

The AWS secret key.

String

camel.vault.azure.client-id

The Client Id.

String

camel.vault.azure.client-secret

The Client secret.

String

camel.vault.azure.tenant-id

The tenant Id.

String

camel.vault.azure.vault-name

The Vault Name.

String

camel.vault.gcp.project-id

The GCP Project ID.

String

camel.vault.gcp.service-account-key

The Service Account Key location.

String

camel.vault.gcp.use-default-instance

Define if we want to use the GCP Client Default Instance or not.

false

Boolean

management.endpoint.camel.cache.time-to-live

Maximum time that a response can be cached.

0ms

Duration

management.endpoint.camel.enabled

Whether to enable the camel endpoint.

true

Boolean

management.endpoint.camelroutecontroller.cache.time-to-live

Maximum time that a response can be cached.

0ms

Duration

management.endpoint.camelroutecontroller.enabled

Whether to enable the camelroutecontroller endpoint.

true

Boolean

management.endpoint.camelroutes.cache.time-to-live

Maximum time that a response can be cached.

0ms

Duration

management.endpoint.camelroutes.enabled

Whether to enable the camelroutes endpoint.

true

Boolean

management.endpoint.camelroutes.read-only

Whether Camel Routes actuator is in read-only mode. If not in read-only mode then operations to start/stop routes would be enabled.

true

Boolean

management.info.camel.enabled

Whether to enable Camel info.

true

Boolean

camel.springboot.route-controller-logging-level

Deprecated Sets the logging level used for logging route activity (such as starting and stopping routes). The default logging level is DEBUG.

LoggingLevel

Auto-configured Camel context

The most important piece of functionality provided by the Camel auto-configuration is CamelContext instance. Camel auto-configuration creates a SpringCamelContext for you and takes care of the proper initialization and shutdown of that context. The created Camel context is also registered in the Spring application context (under camelContext bean name), so you can access it just as any other Spring bean.

@Configuration
public class MyAppConfig {

  @Autowired
  CamelContext camelContext;

  @Bean
  MyService myService() {
    return new DefaultMyService(camelContext);
  }

}

Auto-detecting Camel routes

Camel auto-configuration collects all the RouteBuilder instances from the Spring context and automatically injects them into the provided CamelContext. That means that creating new Camel routes with the Spring Boot starter is as simple as adding the @Component annotated class to your classpath:

@Component
public class MyRouter extends RouteBuilder {

  @Override
  public void configure() throws Exception {
    from("jms:invoices").to("file:/invoices");
  }

}

Or creating a new route RouteBuilder bean in your @Configuration class:

@Configuration
public class MyRouterConfiguration {

  @Bean
  RoutesBuilder myRouter() {
    return new RouteBuilder() {

      @Override
      public void configure() throws Exception {
        from("jms:invoices").to("file:/invoices");
      }

    };
  }

}

Camel properties

Spring Boot auto-configuration automatically connects to Spring Boot external configuration (like properties placeholders, OS environment variables or system properties) with the Camel properties support. It basically means that any property defined in application.properties file:

route.from = jms:invoices

Or set via system property:

java -Droute.to=jms:processed.invoices -jar mySpringApp.jar

…​can be used as placeholders in Camel route:

@Component
public class MyRouter extends RouteBuilder {

  @Override
  public void configure() throws Exception {
    from("{{route.from}}").to("{{route.to}}");
  }

}

Custom Camel context configuration

If you would like to perform some operations on CamelContext bean created by Camel auto-configuration, register CamelContextConfiguration instance in your Spring context:

@Configuration
public class MyAppConfig {

  @Bean
  CamelContextConfiguration contextConfiguration() {
    return new CamelContextConfiguration() {
      @Override
      void beforeApplicationStart(CamelContext context) {
        // your custom configuration goes here
      }
    };
  }

}

Method beforeApplicationStart` will be called just before the Spring context is started, so the CamelContext instance passed to this callback is fully auto-configured. You can add many instances of CamelContextConfiguration into your Spring context - all of them will be executed.

Auto-configured consumer and producer templates

Camel auto-configuration provides pre-configured ConsumerTemplate and ProducerTemplate instances. You can simply inject them into your Spring-managed beans:

@Component
public class InvoiceProcessor {

  @Autowired
  private ProducerTemplate producerTemplate;

  @Autowired
  private ConsumerTemplate consumerTemplate;

  public void processNextInvoice() {
    Invoice invoice = consumerTemplate.receiveBody("jms:invoices", Invoice.class);
    ...
    producerTemplate.sendBody("netty-http:http://invoicing.com/received/" + invoice.id());
  }

}

By default, consumer templates and producer templates come with the endpoint cache sizes set to 1000. You can change those values via the following Spring properties:

camel.springboot.consumer-template-cache-size = 100
camel.springboot.producer-template-cache-size = 200

Auto-configured TypeConverter

Camel auto-configuration registers a TypeConverter instance named typeConverter in the Spring context.

@Component
public class InvoiceProcessor {

  @Autowired
  private TypeConverter typeConverter;

  public long parseInvoiceValue(Invoice invoice) {
    String invoiceValue = invoice.grossValue();
    return typeConverter.convertTo(Long.class, invoiceValue);
  }

}

Spring type conversion API bridge

Spring comes with the powerful type conversion API. Spring API happens to be very similar to the Camel type converter API. As those APIs are so similar, Camel Spring Boot automatically registers a bridge converter (SpringTypeConverter) that delegates to the Spring conversion API.That means that out-of-the-box Camel will treat Spring Converters like Camel ones. With this approach you can enjoy both Camel and Spring converters accessed via Camel TypeConverter API:

@Component
public class InvoiceProcessor {

  @Autowired
  private TypeConverter typeConverter;

  public UUID parseInvoiceId(Invoice invoice) {
    // Using Spring's StringToUUIDConverter
    UUID id = invoice.typeConverter.convertTo(UUID.class, invoice.getId());
  }

}

Under the hood Camel Spring Boot delegates conversion to the Spring’s ConversionService instances available in the application context. If no ConversionService instance is available, Camel Spring Boot auto-configuration will create one for you.

Keeping the application alive

Camel applications having this feature enabled launch a new thread on startup for the sole purpose of keeping the application alive by preventing JVM termination. It means that after you start a Camel application with Spring Boot, your application waits for a Ctrl+C signal and does not exit immediately.

The controller thread can be activated using the camel.springboot.main-run-controller to true.

camel.springboot.main-run-controller = true

Applications using web modules (e.g. importing the org.springframework.boot:spring-boot-web-starter module), usually don’t need to use this feature because the application is kept alive by the presence of other non-daemon threads.

Adding XML routes

By default, you can put Camel XML routes in the classpath under the directory camel, which camel-spring-boot will auto-detect and include. You can configure the directory name or turn this off using the configuration option

# turn off
camel.springboot.routes-include-pattern = false
# scan only in the com/foo/routes classpath
camel.springboot.routes-include-pattern = classpath:com/foo/routes/*.xml

The XML files should be Camel XML routes (not <CamelContext>) such as

<routes xmlns="http://camel.apache.org/schema/spring">
    <route id="test">
        <from uri="timer://trigger"/>
        <transform>
            <simple>ref:myBean</simple>
        </transform>
        <to uri="log:out"/>
    </route>
</routes>

Testing the JUnit 4 way (deprecated)

For testing, Maven users will need to add the following dependencies to their pom.xml:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <version>${spring-boot.version}</version> <!-- Use the same version as your Spring Boot version -->
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-test-spring</artifactId>
    <version>${camel.version}</version> <!-- use the same version as your Camel core version -->
    <scope>test</scope>
</dependency>

To test a Camel Spring Boot application, annotate your test class(es) with @RunWith(CamelSpringBootRunner.class). This brings Camel’s Spring Test support to your application, so that you can write tests using Spring Boot test conventions.

To get the CamelContext or ProducerTemplate, you can inject them into the class in the normal Spring manner, using @Autowired.

You can also use camel-test-spring-junit5 to configure tests declaratively. This example uses the @MockEndpoints annotation to auto-mock an endpoint:

@RunWith(CamelSpringBootRunner.class)
@SpringBootTest
@MockEndpoints("direct:end")
public class MyApplicationTest {

    @Autowired
    private ProducerTemplate template;

    @EndpointInject("mock:direct:end")
    MockEndpoint mock;

    @Test
    public void testReceive() throws Exception {
        mock.expectedBodiesReceived("Hello");
        template.sendBody("direct:start", "Hello");
        mock.assertIsSatisfied();
    }

}

Testing the JUnit 5 way

For testing, Maven users will need to add the following dependencies to their pom.xml:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <version>${spring-boot.version}</version> <!-- Use the same version as your Spring Boot version -->
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-test-spring-junit5</artifactId>
    <version>${camel.version}</version> <!-- use the same version as your Camel core version -->
    <scope>test</scope>
</dependency>

To test a Camel Spring Boot application, annotate your test class(es) with @CamelSpringBootTest. This brings Camel’s Spring Test support to your application, so that you can write tests using Spring Boot test conventions.

To get the CamelContext or ProducerTemplate, you can inject them into the class in the normal Spring manner, using @Autowired.

You can also use camel-test-spring-junit5 to configure tests declaratively. This example uses the @MockEndpoints annotation to auto-mock an endpoint:

@CamelSpringBootTest
@SpringBootApplication
@MockEndpoints("direct:end")
public class MyApplicationTest {

    @Autowired
    private ProducerTemplate template;

    @EndpointInject("mock:direct:end")
    private MockEndpoint mock;

    @Test
    public void testReceive() throws Exception {
        mock.expectedBodiesReceived("Hello");
        template.sendBody("direct:start", "Hello");
        mock.assertIsSatisfied();
    }

}