Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Integrating systems with Apache Camel and Quarkus on Red Hat OpenShift

May 18, 2021
Peter Palaga
Related topics:
ContainersJavaKubernetesQuarkus
Related products:
Red Hat OpenShift

    Apache Camel has been a massively successful tool for integrating heterogeneous systems for more than a decade. You have probably dealt with a situation where you have two systems that were not designed to communicate with each other but still need to exchange data. That's exactly the kind of situation where Camel and its integration pipelines can help. This article shows how Quarkus uses Camel.

    Figure 1 shows Camel's basic operation: Data from one system passes through a transport designed for that system to a transport designed for the recipient system.

    Diagram shows data passing from System A through a System A Transport, and data passing from System B through a System B Transport. The two systems are connected via a Route.
    Figure 1: A basic Camel integration route.

    Traditionally, Camel integrations have been deployed on various Java platforms, such as Spring Boot, Karaf, and Red Hat JBoss Enterprise Application Platform (JBoss EAP). Thanks to work done in the Camel Quarkus community project, it is now possible to run Camel integrations on Quarkus. The main benefit is that integrations start faster and consume less RAM. But Quarkus dev mode also brings developer-productivity benefits. The container-first ethos is also not to be forgotten.

    This article shows how to use Camel with Quarkus on Red Hat OpenShift.

    Defining Camel routes

    Let's go through all the parts of a Camel integration and see them in more detail through an example. The source code of the example is available on GitHub.

    Say that you need to process CSV files stored in a local directory by an external system. Those files contain book records consisting of a book title, author name, and genre. You want to split the records into separate CSV files by genre and store them on a remote SFTP server.

    To accomplish this project, define a few Camel routes. The first route is ancillary, to simulate the external system that produces the CSV files containing the book data:

    import org.apache.camel.Exchange;
    import org.apache.camel.builder.RouteBuilder;
    import org.apache.camel.model.dataformat.BindyType;
    import org.apache.camel.processor.aggregate.GroupedBodyAggregationStrategy;
    
    public class Routes extends RouteBuilder {
    
        @Override
        public void configure() throws Exception {
            // Route 1: Generate some book objects with random data
            from("timer:generateBooks?period={{timer.period}}&delay={{timer.delay}}")
                    .log("Generating randomized books CSV data")
                    .process("bookGenerator")
                    // Marshal each book to CSV format
                    .marshal().bindy(BindyType.Csv, Book.class)
                    // Write CSV data to file
                    .to("file:{{csv.location}}");
    
            // More route definitions come here...
    
        }
    }

    The second route parses the discovered CSV files into a list of plain old Java objects (POJOs) using Camel Bindy. That list is split into individual Book objects via split(body()) and passed to another Camel endpoint called direct:aggregateBooks:

            ...
    
            // Route 2: Consume book CSV files
            from("file:{{csv.location}}?delay=1000")
                    .log("Reading books CSV data from ${header.CamelFileName}")
                    .unmarshal().bindy(BindyType.Csv, Book.class)
                    .split(body())
                    .to("direct:aggregateBooks");
    
            // More route definitions come here...

    The third route picks the Book objects produced by the previous route, does the aggregation (producing a list of Books per genre), and passes them to the last route:

            ...
    
            // Route 3: Aggregate books based on their genre
            from("direct:aggregateBooks")
                    .setHeader("BookGenre", simple("${body.genre}"))
                    .aggregate(simple("${body.genre}"), new GroupedBodyAggregationStrategy()).completionInterval(5000)
                    .log("Processed ${header.CamelAggregatedSize} books for genre '${header.BookGenre}'")
                    .to("seda:processed");
    
            // One more route definition comes here...

    The fourth route serializes aggregated lists of Book records back to CSV and stores them on a remote SFTP server:

            ...
    
            // Route 4: Marshal books back to CSV format
            from("seda:processed")
                    .marshal().bindy(BindyType.Csv, Book.class)
                    .setHeader(Exchange.FILE_NAME, simple("books-${header.BookGenre}-${exchangeId}.csv"))
                    // Send aggregated book genre CSV files to an FTP host
                    .to("sftp://{{ftp.username}}@{{ftp.host}}:{{ftp.port}}/uploads/books?password={{ftp.password}}")
                    .log("Uploaded ${header.CamelFileName}");

    The pom.xml file

    For a plain Camel project, you would have to list the Camel component artifacts (camel-bindy, camel-seda, etc.) as dependencies in your pom.xml file. For a Camel Quarkus project, you'll have to list their Camel Quarkus counterparts (camel-quarkus-bindy, camel-quarkus-seda, etc.). Import org.apache.camel.quarkus:camel-quarkus-bom to manage the versions of the dependencies:

    <project>
        ...
    
        <properties>
            <camel-quarkus.version>1.6.0.fuse-jdk11-800006-redhat-00001</camel-quarkus.version>
            <quarkus.version>1.11.6.Final-redhat-00001</quarkus.version>
            ...
        </properties>
    
        <dependencyManagement>
            <dependencies>
                <!-- Import BOM -->
                <dependency>
                    <groupId>org.apache.camel.quarkus</groupId>
                    <artifactId>camel-quarkus-bom</artifactId>
                    <version>${camel-quarkus.version}</version>
                    <type>pom</type>
                    <scope>import</scope>
                </dependency>
            </dependencies>
        </dependencyManagement>
    
        <dependencies>
            <dependency>
                <groupId>org.apache.camel.quarkus</groupId>
                <artifactId>camel-quarkus-bean</artifactId>
            </dependency>
            <dependency>
                <groupId>org.apache.camel.quarkus</groupId>
                <artifactId>camel-quarkus-bindy</artifactId>
            </dependency>
            <dependency>
                <groupId>org.apache.camel.quarkus</groupId>
                <artifactId>camel-quarkus-direct</artifactId>
            </dependency>
            <dependency>
                <groupId>org.apache.camel.quarkus</groupId>
                <artifactId>camel-quarkus-file</artifactId>
            </dependency>
            <dependency>
                <groupId>org.apache.camel.quarkus</groupId>
                <artifactId>camel-quarkus-ftp</artifactId>
            </dependency>
    
            ...
    
        </dependencies>
    
        ...
    </project>

    Runtime prerequisites

    To run the example, you need an SFTP server. For testing, you can use a Docker container as follows:

    $ docker run -ti --rm -p 2222:2222 \
    -e PASSWORD_ACCESS=true \
    -e USER_NAME=ftpuser \
    -e USER_PASSWORD=ftppassword \
    -e DOCKER_MODS=linuxserver/mods:openssh-server-openssh-client \
    linuxserver/openssh-server

    Quarkus dev mode

    Having all that in place, you can build the project and start Quarkus in dev mode:

    $ mvn clean compile quarkus:dev

    This mode lets the Quarkus tooling watch for changes in your workspace and recompile and redeploy the application upon any change. Please refer to the development mode section of the Camel Quarkus user guide for more details.

    You should start to see log messages appearing on the console, like the following:

    [route1] (Camel (camel-1) thread #3 - timer://generateBooks) Generating randomized books CSV data
    [route2] (Camel (camel-1) thread #1 - file:///tmp/books) Reading books CSV data from 89A0EE24CB03A69-0000000000000000
    [route3] (Camel (camel-1) thread #0 - AggregateTimeoutChecker) Processed 34 books for genre 'Action'
    [route3] (Camel (camel-1) thread #0 - AggregateTimeoutChecker) Processed 31 books for genre 'Crime'
    [route3] (Camel (camel-1) thread #0 - AggregateTimeoutChecker) Processed 35 books for genre 'Horror'

    You can try changing something in Routes.java and see that the application gets live-reloaded after saving the file.

    Packaging and running the application

    Once you are done with development, you can package and run the application:

    $ mvn clean package -DskipTests
    $ java -jar target/*-runner.jar

    Deploying to OpenShift

    To deploy the application to OpenShift, run the following command:

    $ mvn clean package -DskipTests -Dquarkus.kubernetes.deploy=true

    Check that the pods are running:

    $ oc get pods
    
    NAME READY STATUS RESTARTS AGE
    camel-quarkus-examples-file-bindy-ftp-5d48f4d85c-sjl8k 1/1 Running 0 21s
    ssh-server-deployment-5c667bccfc-52xfz 1/1 Running 0 21s

    Tail the application logs, and you should see messages similar to those in dev mode:

    $ oc logs -f camel-quarkus-examples-file-bindy-ftp-5d48f4d85c-sjl8k

    About Camel Quarkus technology preview

    Camel Quarkus is available as a technology preview (TP) component in Red Hat Integration 2021 Q2. Technology preview features provide early access to upcoming product innovations, enabling you to test functionality and provide feedback during the development process. As we move towards general availability (GA) later this year, each preview release will focus on key use cases.

    The following Quarkus extensions are included in this technology preview:

    • camel-quarkus-bean
    • camel-quarkus-bindy
    • camel-quarkus-core
    • camel-quarkus-direct
    • camel-quarkus-file
    • camel-quarkus-ftp
    • camel-quarkus-log
    • camel-quarkus-main
    • camel-quarkus-microprofile-health
    • camel-quarkus-mock
    • camel-quarkus-seda
    • camel-quarkus-timer

    These extensions are supported in JVM mode only.

    Note that more Camel Quarkus extensions are provided by the Apache Camel community. These extensions can be combined with the extensions provided by Red Hat Integration.

    For more details, please refer to the release notes.

    Your feedback is welcome via the Red Hat Support Portal.

     

    Last updated: September 19, 2023

    Related Posts

    • Modernizing applications with Apache Camel, JavaScript, and Red Hat OpenShift

    • Boost Apache Camel performance on Quarkus

    • Choose the best Camel for your integration ride, Part 1

    • No-code and low-code integrations with Camel and Kaoto

    • How Kamelets simplify Camel integrations on Kubernetes

    Recent Posts

    • MCP servers vs. skills: Choosing the right context for your AI

    • How to route external and local LLMs with Models-as-a-Service

    • Protect data offloaded to GPU-accelerated environments with OpenShift sandboxed containers

    • Case study: Measuring energy efficiency on the x64 platform

    • How to prevent AI inference stack silent failures

    What’s up next?

    Learn how to deploy an application on a cluster using Red Hat OpenShift Service on AWS. This learning path uses a pre-built application to allow you to become more familiar with OpenShift and Kubernetes features.

    Start learning
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.