Getting Started with Camel Spring Boot 3.14

Red Hat Integration 2023.q1

Getting Started with Camel Spring Boot

Red Hat Integration Documentation Team Integration Support Team http://access.redhat.com/support

Abstract

This guide introduces Camel Spring Boot and explains the various ways to create and deploy an application using Camel Spring Boot.

Preface

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. We are beginning with these four terms: master, slave, blacklist, and whitelist. Because of the enormity of this endeavor, these changes will be implemented gradually over several upcoming releases. For more details, see our CTO Chris Wright’s message.

Chapter 1. Getting Started with Camel Spring Boot

This guide introduces Camel Spring Boot and demonstrates how to get started building an application using Camel Spring Boot:

1.1. Camel Spring Boot starters

Camel support for Spring Boot provides auto-configuration of the Camel and starters for many Camel components. The opinionated auto-configuration of the Camel context auto-detects Camel routes available in the Spring context and registers the key Camel utilities (such as producer template, consumer template and the type converter) as beans.

Note

For information about using a Maven archtype to generate a Camel for Spring Boot application see Generating a Camel for Spring Boot application using Maven.

To get started, you must add the Camel Spring Boot BOM to your Maven pom.xml file.

<dependencyManagement>

    <dependencies>
        <!-- Camel BOM -->
        <dependency>
            <groupId>org.apache.camel.springboot</groupId>
            <artifactId>camel-spring-boot-bom</artifactId>
            <version>3.14.5.redhat-00032</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <!-- ... other BOMs or dependencies ... -->
    </dependencies>

</dependencyManagement>

The camel-spring-boot-bom is a basic BOM that contains the list of Camel Spring Boot starter JARs.

Next, add the Camel Spring Boot starter to startup the Camel Context.

    <dependencies>
        <!-- Camel Starter -->
        <dependency>
            <groupId>org.apache.camel.springboot</groupId>
            <artifactId>camel-spring-boot-starter</artifactId>
        </dependency>
        <!-- ... other dependencies ... -->
    </dependencies>

You must also add any component starters that your Spring Boot application requires. The following example shows how to add the auto-configuration starter to the ActiveMQ component

    <dependencies>
        <!-- ... other dependencies ... -->
        <dependency>
            <groupId>org.apache.camel.springboot</groupId>
            <artifactId>camel-activemq-starter</artifactId>
        </dependency>
    </dependencies>

1.1.1. Camel Spring Boot BOM vs Camel Spring Boot Dependencies BOM

The curated camel-spring-boot-dependencies BOM, which is generated, contains the adjusted JARs that both Spring Boot and Apache Camel use to avoid any conflicts. This BOM is used to test camel-spring-boot itself.

Spring Boot users may choose to use pure Camel dependencies by using the camel-spring-boot-bom that only has the Camel starter JARs as managed dependencies. However, this may lead to a classpath conflict if a third-party JAR from Spring Boot is not compatible with a particular Camel component.

1.1.2. Spring Boot configuration support

Each starter lists configuration parameters you can configure in the standard application.properties or application.yml files. These parameters have the form of camel.component.[component-name].[parameter]. For example to configure the URL of the ActiveMQ broker you can set:

camel.component.activemq.broker-url=tcp://localhost:61616

1.1.3. Adding Camel routes

Camel routes are detected in the Spring application context, for example a route annotated with org.springframework.stereotype.Component will be loaded, added to the Camel context and run.

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

@Component
public class MyRoute extends RouteBuilder {

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

}

1.2. Spring Boot

Spring Boot automatically configures Camel for you. The 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>3.14.5.redhat-00032</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.

1.2.1. 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>3.14.5.redhat-00032</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.

1.2.2. 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>3.14.5.redhat-00032</version> <!-- use the same version as your Camel core version -->
</dependency>

1.2.3. Auto-configured Camel context

The most important piece of functionality provided by the Camel auto-configuration is the 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 the camelContext bean name), so you can access it like any other Spring bean.

@Configuration
public class MyAppConfig {

  @Autowired
  CamelContext camelContext;

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

}

1.2.4. Auto-detecting Camel routes

Camel auto-configuration collects all the RouteBuilder instances from the Spring context and automatically injects them into the provided CamelContext. This 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");
      }

    };
  }

}

1.2.5. Camel properties

Spring Boot auto-configuration automatically connects to Spring Boot external configuration (which may contain 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}}");
  }

}

1.2.6. Custom Camel context configuration

If you want 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
      }
    };
  }

}

The method beforeApplicationStart will be called just before the Spring context is started, so the CamelContext instance passed to this callback is fully auto-configured. If you add multiple instances of CamelContextConfiguration into your Spring context, each instance is executed.

1.2.7. 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 these values by modifying the following Spring properties:

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

1.2.8. 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);
  }

}

1.2.8.1. Spring type conversion API bridge

Spring comes with the powerful type conversion API. The Spring API is similar to the Camel type converter API. As both APIs are so similar, Camel Spring Boot automatically registers a bridge converter (SpringTypeConverter) that delegates to the Spring conversion API. This means that out-of-the-box Camel will treat Spring Converters like Camel ones. With this approach you can use 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.

1.2.9. Keeping the application alive

Camel applications which have this feature enabled launch a new thread on startup for the sole purpose of keeping the application alive by preventing JVM termination. This 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 (for example, applications that import 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.

1.2.10. 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>

1.2.11. 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>2.7.4</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>3.14.5.redhat-00018</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();
    }

}

1.3. Component Starters

Camel Spring Boot supports the following Camel artifacts as Spring Boot Starters:

Note

Reference documentation is not yet available for some of the artifacts listed below. This documentation will be released as soon as it is available.

Table 1.1. Camel Components

ComponentArtifactDescription

AWS Cloudwatch

camel-aws2-cw-starter

Sending metrics to AWS CloudWatch using AWS SDK version 2.x.

AWS DynamoDB

camel-aws2-ddb-starter

Store and retrieve data from AWS DynamoDB service using AWS SDK version 2.x.

AWS Kinesis

camel-aws2-kinesis-starter

Consume and produce records from and to AWS Kinesis Streams using AWS SDK version 2.x.

AWS Lambda

camel-aws2-lambda-starter

Manage and invoke AWS Lambda functions using AWS SDK version 2.x.

AWS S3 Storage Service

camel-aws2-s3-starter

Store and retrieve objects from AWS S3 Storage Service using AWS SDK version 2.x.

AWS Simple Notification System (SNS)

camel-aws2-sns-starter

Send messages to an AWS Simple Notification Topic using AWS SDK version 2.x.

AWS Simple Queue Service (SQS)

camel-aws2-sqs-starter

Send and receive messages to/from AWS SQS service using AWS SDK version 2.x.

Azure Storage Blob Service

camel-azure-storage-blob-starter

Store and retrieve blobs from Azure Storage Blob Service using SDK v12.

Azure Storage Queue Service

camel-azure-storage-queue-starter

The azure-storage-queue component is used for storing and retrieving the messages to/from Azure Storage Queue using Azure SDK v12.

Bean

camel-bean-starter

Invoke methods of Java beans stored in Camel registry.

Bean Validator

camel-bean-validator-starter

Validate the message body using the Java Bean Validation API.

Browse

camel-browse-starter

Inspect the messages received on endpoints supporting BrowsableEndpoint.

Cassandra CQL

camel-cassandraql-starter

Integrate with Cassandra 2.0 using the CQL3 API (not the Thrift API). Based on Cassandra Java Driver provided by DataStax.

Control Bus

camel-controlbus-starter

Manage and monitor Camel routes.

Cron

camel-cron-starter

A generic interface for triggering events at times specified through the Unix cron syntax.

CXF

camel-cxf-soap-starter

Expose SOAP WebServices using Apache CXF or connect to external WebServices using CXF WS client.

Data Format

camel-dataformat-starter

Use a Camel Data Format as a regular Camel Component.

Dataset

camel-dataset-starter

Provide data for load and soak testing of your Camel application.

Direct

camel-direct-starter

Call another endpoint from the same Camel Context synchronously.

FHIR

camel-fhir-starter

Exchange information in the healthcare domain using the FHIR (Fast Healthcare Interoperability Resources) standard.

File

camel-file-starter

Read and write files.

FTP

camel-ftp-starter

Upload and download files to/from FTP servers.

HTTP

camel-http-starter

Send requests to external HTTP servers using Apache HTTP Client 4.x.

Infinispan

camel-infinispan-starter

Read and write from/to Infinispan distributed key/value store and data grid.

Jira

camel-jira-starter

Interact with JIRA issue tracker.

JMS

camel-jms-starter

Sent and receive messages to/from a JMS Queue or Topic.

Kafka

camel-kafka-starter

Sent and receive messages to/from an Apache Kafka broker.

Kamelet

camel-kamelet-starter

To call Kamelets

Language

camel-language-starter

Execute scripts in any of the languages supported by Camel.

Log

camel-log-starter

Log messages to the underlying logging mechanism.

Mail

camel-mail-starter

Send and receive emails using imap, pop3 and smtp protocols.

Master

camel-master-starter

Have only a single consumer in a cluster consuming from a given endpoint; with automatic failover if the JVM dies.

MLLP

camel-mllp-starter

Communicate with external systems using the MLLP protocol.

Mock

camel-mock-starter

Test routes and mediation rules using mocks.

MongoDB

camel-mongodb-starter

Perform operations on MongoDB documents and collections.

Netty

camel-netty-starter

Socket level networking using TCP or UDP with Netty 4.x.

Paho

camel-paho-starter

Communicate with MQTT message brokers using Eclipse Paho MQTT Client.

Paho MQTT 5

camel-paho-mqtt5-starter

Communicate with MQTT message brokers using Eclipse Paho MQTT v5 Client.

Quartz

camel-quartz-starter

Schedule sending of messages using the Quartz 2.x scheduler.

Ref

camel-ref-starter

Route messages to an endpoint looked up dynamically by name in the Camel Registry.

REST

camel-rest-starter

Expose REST services or call external REST services.

Salesforce

camel-salesforce-starter

Communicate with Salesforce using Java DTOs.

Scheduler

camel-scheduler-starter

Generate messages in specified intervals using java.util.concurrent.ScheduledExecutorService.

SEDA

camel-seda-starter

Asynchronously call another endpoint from any Camel Context in the same JVM.

Servlet

camel-servlet-starter

Serve HTTP requests by a Servlet.

Slack

camel-slack-starter

Send and receive messages to/from Slack.

SQL

camel-sql-starter

Perform SQL queries using Spring JDBC.

Stub

camel-stub-starter

Stub out any physical endpoints while in development or testing.

Telegram

camel-telegram-starter

Send and receive messages acting as a Telegram Bot Telegram Bot API.

Timer

camel-timer-starter

Generate messages in specified intervals using java.util.Timer.

Validator

camel-validator-starter

Validate the payload using XML Schema and JAXP Validation.

Webhook

camel-webhook-starter

Expose webhook endpoints to receive push notifications for other Camel components.

XSLT

camel-xslt-starter

Transforms XML payload using an XSLT template.

Table 1.2. Camel Data Formats

ComponentArtifactDescription

Avro

camel-avro-starter

Serialize and deserialize messages using Apache Avro binary data format.

Avro Jackson

camel-jackson-avro-starter

Marshal POJOs to Avro and back using Jackson.

Bindy

camel-bindy-starter

Marshal and unmarshal between POJOs and key-value pair (KVP) format using Camel Bindy

HL7

camel-hl7-starter

Marshal and unmarshal HL7 (Health Care) model objects using the HL7 MLLP codec.

JacksonXML

camel-jacksonxml-starter

Unmarshal a XML payloads to POJOs and back using XMLMapper extension of Jackson.

JAXB

camel-jaxb-starter

Unmarshal XML payloads to POJOs and back using JAXB2 XML marshalling standard.

JSON Gson

camel-gson-starter

Marshal POJOs to JSON and back using Gson

JSON Jackson

camel-jackson-starter

Marshal POJOs to JSON and back using Jackson

Protobuf Jackson

camel-jackson-protobuf-starter

Marshal POJOs to Protobuf and back using Jackson.

SOAP

camel-soap-starter

Marshal Java objects to SOAP messages and back.

Zip File

camel-zipfile-starter

Compression and decompress streams using java.util.zip.ZipStream.

Table 1.3. Camel Languages

LanguageArtifactDescription

Constant

camel-core-starter

A fixed value set only once during the route startup.

CSimple

camel-core-starter

Evaluate a compiled simple expression.

ExchangeProperty

camel-core-starter

Gets a property from the Exchange.

File

camel-core-starter

File related capabilities for the Simple language.

Header

camel-core-starter

Gets a header from the Exchange.

JSONPath

camel-jsonpath-starter

Evaluates a JSONPath expression against a JSON message body.

Ref

camel-core-starter

Uses an existing expression from the registry.

Simple

camel-core-starter

Evaluates a Camel simple expression.

Tokenize

camel-core-starter

Tokenize text payloads using delimiter patterns.

XML Tokenize

camel-xml-jaxp-starter

Tokenize XML payloads.

XPath

camel-xpath-starter

Evaluates an XPath expression against an XML payload.

XQuery

camel-saxon-starter

Query and/or transform XML payloads using XQuery and Saxon.

Table 1.4. Miscellaneous Extensions

ExtensionsArtifactDescription

Openapi Java

camel-openapi-java-starter

Rest-dsl support for using openapi doc

1.4. Starter Configuration

Clear and accessible configuration is a crucial part of any application. Camel starters fully support Spring Boot’s external configuration mechanism. You can also configure them through Spring Beans for more complex use cases.

1.4.1. Using External Configuration

Internally, every starter is configured through Spring Boot’s ConfigurationProperties. Each configuration parameter can be set in various ways (application.[properties|json|yaml] files, command line arguments, environments variables etc.). Parameters have the form of camel.[component|language|dataformat].[name].[parameter]

For example to configure the URL of the ActiveMQ broker you can set:

camel.component.activemq.broker-url=tcp://localhost:61616

Or to configure the delimeter of the CSV dataformat to be a semicolon(;) you can set:

camel.dataformat.csv.delimiter=;

Camel will use the Type Converter mechanism when setting properties to the desired type.

You can refer to beans in the Registry using the #bean:name:

camel.component.jms.transactionManager=#bean:myjtaTransactionManager

The Bean would be typically created in Java:

@Bean("myjtaTransactionManager")
public JmsTransactionManager myjtaTransactionManager(PooledConnectionFactory pool) {
    JmsTransactionManager manager = new JmsTransactionManager(pool);
    manager.setDefaultTimeout(45);
    return manager;
}

Beans can also be created in configuration files but this is not recommended for complex use cases.

1.4.2. Using Beans

Starters can also be created and configured via Spring Beans. Before creating a starter , Camel will first lookup it up in the Registry by it’s name if it already exists. For example to configure a Kafka component:

@Bean("kafka")
public KafkaComponent kafka(KafkaConfiguration kafkaconfiguration){
    return ComponentsBuilderFactory.kafka()
                        .brokers("{{kafka.host}}:{{kafka.port}}")
                        .build();
}

The Bean name has to be equal to that of the Component, Dataformat or Language that you are configuring. If the Bean name isn’t specified in the annotation it will be set to the method name.

Typical Camel Spring Boot projects will use a combination of external configuration and Beans to configure an application. For more examples on how to configure your Camel Spring Boot project, please see the example repository.

1.5. Generating a Camel for Spring Boot application using Maven

You can generate a Camel Spring Boot application using the Maven archetype org.apache.camel.archetypes:camel-archetype-spring-boot:3.14.5.redhat-00032.

Procedure

  1. Run the following command:

    mvn archetype:generate \
     -DarchetypeGroupId=org.apache.camel.archetypes \
     -DarchetypeArtifactId=camel-archetype-spring-boot \
     -DarchetypeVersion=3.14.5.redhat-00032 \
     -DgroupId=com.redhat \
     -DartifactId=csb-app \
     -Dversion=1.0-SNAPSHOT \
     -DinteractiveMode=false
  2. Build the application:

    mvn package -f csb-app/pom.xml
  3. Run the application:

    java -jar csb-app/target/csb-app-1.0-SNAPSHOT.jar
  4. Verify that the application is running by examining the console log for the Hello World output which is generated by the application.

    com.redhat.MySpringBootApplication       : Started MySpringBootApplication in 3.514 seconds (JVM running for 4.006)
    Hello World
    Hello World

Chapter 2. Migrating to Camel Spring Boot

This guide provides information on migrating from Red Hat Fuse 7 to Camel 3 on Spring Boot.

2.1. Java versions

Camel 3 supports Java 11 but not Java 8. In Java 11 the JAXB modules have been removed from the JDK, therefore you will need to add them as Maven dependencies (if you use JAXB such as when using XML DSL or the camel-jaxb component):

<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.1</version>
</dependency>

<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-core</artifactId>
    <version>2.3.0.1</version>
</dependency>

<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-impl</artifactId>
    <version>2.3.2</version>
</dependency>

2.2. Modularization of camel-core

In Camel 3.x, camel-core has been split into many JARs as follows:

  • camel-api
  • camel-base
  • camel-caffeine-lrucache
  • camel-cloud
  • camel-core
  • camel-jaxp
  • camel-main
  • camel-management-api
  • camel-management
  • camel-support
  • camel-util
  • camel-util-json

Maven users of Apache Camel can keep using the dependency camel-core which has transitive dependencies on all of its modules, except for camel-main, and therefore no migration is needed.

2.3. Modularization of Components

In Camel 3.x, some of the camel-core components are moved into individual components.

  • camel-attachments
  • camel-bean
  • camel-browse
  • camel-controlbus
  • camel-dataformat
  • camel-dataset
  • camel-direct
  • camel-directvm
  • camel-file
  • camel-language
  • camel-log
  • camel-mock
  • camel-ref
  • camel-rest
  • camel-saga
  • camel-scheduler
  • camel-seda
  • camel-stub
  • camel-timer
  • camel-validator
  • camel-vm
  • camel-xpath
  • camel-xslt
  • camel-xslt-saxon
  • camel-zip-deflater

2.4. Changes to Spring Boot starters

The Maven groupId for the Spring Boot starters is changed from org.apache.camel to org.apache.camel.springboot.

Example

Use:

<dependency>
  <groupId>org.apache.camel.springboot</groupId>
  <artifactId>camel-component-starter</artifactId>
</dependency>

Instead of

<dependency>
  <groupId>org.apache.camel</groupId>
  <artifactId>camel-component-starter</artifactId>
</dependency>

2.5. Multiple CamelContexts per application not supported

Support for multiple CamelContexts has been removed and only one CamelContext per deployment is recommended and supported. The context attribute on the various Camel annotations such as @EndpointInject, @Produce, @Consume etc. has therefore been removed.

2.6. Deprecated APIs and Components

All deprecated APIs and components from Camel 2.x have been removed in Camel 3.

2.6.1. Removed components

All deprecated components from Camel 2.x are removed in Camel 3.x, including the old camel-http, camel-hdfs, camel-mina, camel-mongodb, camel-netty, camel-netty-http, camel-quartz, camel-restlet and camel-rx components.

  • Removed camel-jibx component.
  • Removed camel-boon dataformat.
  • Removed the camel-linkedin component as the Linkedin API 1.0 is no longer supported. Support for the new 2.0 API is tracked by CAMEL-13813.
  • The camel-zookeeper has its route policy functionality removed, instead use ZooKeeperClusterService or the camel-zookeeper-master component.
  • The camel-jetty component no longer supports producer (which has been removed), use camel-http component instead.
  • The twitter-streaming component has been removed as it relied on the deprecated Twitter Streaming API and is no longer functional.

2.6.2. Renamed components

Following components are renamed in Camel 3.x.

  • The test component has been renamed to dataset-test and moved out of camel-core into camel-dataset JAR.
  • The http4 component has been renamed to http, and it’s corresponding component package from org.apache.camel.component.http4 to org.apache.camel.component.http. The supported schemes are now only http and https.
  • The hdfs2 component has been renamed to hdfs, and it’s corresponding component package from org.apache.camel.component.hdfs2 to org.apache.camel.component.hdfs. The supported scheme is now hdfs.
  • The mina2 component has been renamed to mina, and it’s corresponding component package from org.apache.camel.component.mina2 to org.apache.camel.component.mina. The supported scheme is now mina.
  • The mongodb3 component has been renamed to mongodb, and it’s corresponding component package from org.apache.camel.component.mongodb3 to org.apache.camel.component.mongodb. The supported scheme is now mongodb.
  • The netty4-http component has been renamed to netty-http, and it’s corresponding component package from org.apache.camel.component.netty4.http to org.apache.camel.component.netty.http. The supported scheme is now netty-http.
  • The netty4 component has been renamed to netty, and it’s corresponding component package from org.apache.camel.component.netty4 to org.apache.camel.component.netty. The supported scheme is now netty.
  • The quartz2 component has been renamed to quartz, and it’s corresponding component package from org.apache.camel.component.quartz2 to org.apache.camel.component.quartz. The supported scheme is now quartz.
  • The rxjava2 component has been renamed to rxjava, and it’s corresponding component package from org.apache.camel.component.rxjava2 to org.apache.camel.component.rxjava.
  • Renamed camel-jetty9 to camel-jetty. The supported scheme is now jetty.

2.6.3. Mock component

The mock component has been moved out of camel-core. Because of this a number of methods on its assertion clause builder are removed.

2.6.4. ActiveMQ

If you are using the activemq-camel component, then you should migrate to use camel-activemq component, where the component name has changed from org.apache.activemq.camel.component.ActiveMQComponent to org.apache.camel.component.activemq.ActiveMQComponent.

2.6.5. AWS

The component camel-aws has been split into multiple components:

  • camel-aws-cw
  • camel-aws-ddb (which contains both ddb and ddbstreams components)
  • camel-aws-ec2
  • camel-aws-iam
  • camel-aws-kinesis (which contains both kinesis and kinesis-firehose components)
  • camel-aws-kms
  • camel-aws-lambda
  • camel-aws-mq
  • camel-aws-s3
  • camel-aws-sdb
  • camel-aws-ses
  • camel-aws-sns
  • camel-aws-sqs
  • camel-aws-swf
Note

It is recommended to add specifc dependencies for these components.

2.6.6. FHIR

The camel-fhir component has upgraded it’s hapi-fhir dependency to 4.1.0. The default FHIR version has been changed to R4. Therefore if DSTU3 is desired it has to be explicitly set.

2.6.7. Kafka

The camel-kafka component has removed the options bridgeEndpoint and circularTopicDetection as this is no longer needed as the component is acting as bridging would work on Camel 2.x. In other words camel-kafka will send messages to the topic from the endpoint uri. To override this use the KafkaConstants.OVERRIDE_TOPIC header with the new topic. See more details in the camel-kafka component documentation.

2.6.8. Telegram

The camel-telegram component has moved the authorization token from uri-path to a query parameter instead, e.g. migrate

telegram:bots/myTokenHere

to

telegram:bots?authorizationToken=myTokenHere

2.6.9. JMX

If you run Camel standalone with just camel-core as a dependency, and you want JMX enabled out of the box, then you need to add camel-management as a dependency.

For using ManagedCamelContext you now need to get this an extension from CamelContext as follows:

ManagedCamelContext managed = camelContext.getExtension(ManagedCamelContext.class);

2.6.10. XSLT

The XSLT component has moved out of camel-core into camel-xslt and camel-xslt-saxon. The component is separated so camel-xslt is for using the JDK XSTL engine (Xalan), and camel-xslt-saxon is when you use Saxon. This means that you should use xslt and xslt-saxon as component name in your Camel endpoint URIs. If you are using XSLT aggregation strategy, then use org.apache.camel.component.xslt.saxon.XsltSaxonAggregationStrategy for Saxon support. And use org.apache.camel.component.xslt.saxon.XsltSaxonBuilder for Saxon support if using xslt builder. Also notice that allowStax is also only supported in camel-xslt-saxon as this is not supported by the JDK XSLT.

2.6.11. XML DSL Migration

The XML DSL has been changed slightly.

The custom load balancer EIP has changed from <custom> to <customLoadBalancer>

The XMLSecurity data format has renamed the attribute keyOrTrustStoreParametersId to keyOrTrustStoreParametersRef in the <secureXML> tag.

The <zipFile> data format has been renamed to <zipfile>.

2.7. Migrating Camel Maven Plugins

The camel-maven-plugin has been split up into two maven plugins:

camel-maven-plugin
camel-maven-plugin has the run goal, which is intended for quickly running Camel applications standalone. See https://camel.apache.org/manual/camel-maven-plugin.html for more information.
camel-report-maven-plugin
The camel-report-maven-plugin has the validate and route-coverage goals which is used for generating reports of your Camel projects such as validating Camel endpoint URIs and route coverage reports, etc. See https://camel.apache.org/manual/camel-report-maven-plugin.html for more information.

Legal Notice

Copyright © 2023 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at http://creativecommons.org/licenses/by-sa/3.0/. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.