Skip to main content
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 Red Hat 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

    • Red Hat OpenShift AI
    • 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.

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

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

ConsoleDocsSupport Search
New For you

Recommended

We'll recommend resources you may like as you browse. Try these suggestions for now.

  • Product downloads
  • Cheat sheets
  • Red Hat Developer learning portal
  • Developer blog
  • E-books
  • Developer Sandbox
Log in

Get more with a Red Hat Developer account

  • Product downloads
  • Console access
  • Event registration
  • Training & trials
Explore more account benefitsLog in or register

A subscription may be required for some services.

Contact us

Using Camel-Undertow component supporting http2 connection

December 12, 2017
Chandra Shekhar Pandey
Related topics:
ContainersDeveloper toolsDevOpsJavaKubernetesMicroservices
Related products:
Streams for Apache KafkaDeveloper ToolsetRed Hat FuseRed Hat OpenShift Container Platform

    This article would help to configure http2 protocol support for the camel-undertow component.

    • Camel's undertow component use embedded undertow web-container of version undertow-core:jar:1.4.21. This version also supports the http2 connection.
    • I have used camel version 2.21.0-SNAPSHOT from upstream https://github.com/apache/camel.
    • Also, the curl version to test application using camel-undertow component is 7.53.1. This curl version supports --http2 flag for sending an http2 request.
    • I have also used nghttp to test application from linux terminal. However, this article is not about http2 insights.
    • For http2 details, I found articles [1] and [2] helpful.

    1. The project structure is depicted below.

    [csp@dhcppc1 undertow-camel-testing]$ tree
    .
    ├── pom.xml
    ├── README.md
    └── src
        └── main
            └── resources
                └── META-INF
                    └── spring
                        └── camel-context.xml

    2. In pom.xml, we would have to setup the following dependencies.

    <dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-core</artifactId>
    <version>${camel.version}</version>
    </dependency>
    <dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-spring</artifactId>
    <version>${camel.version}</version>
    </dependency>
    <dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-undertow</artifactId>
    <version>${camel.version}</version>
    </dependency>
    <dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-http-common</artifactId>
    <version>${camel.version}</version>
    </dependency>

    3. With camel version:

    <properties>
    <camel.version>2.21.0-SNAPSHOT</camel.version>
    </properties>

    4. Now, one can use spring-based dsl and configure camel-undertow component below way. Let say we named this file as camel-context.xml.

    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
    <camelContext id="cbr-example-context" xmlns="http://camel.apache.org/schema/spring">
    <route id="cbr-route" trace="true">
    <from id="_from1" uri="undertow:http://localhost:7766/foo/bar"/>
    <setBody id="_setBody1">
    <constant&gt;Sending Response&lt;/constant>
    </setBody>
    <log id="_log5" message="Headers ${in.headers}"/>
    <log id="_log5" message="Done processing ${body}"/>
    </route>
    </camelContext>
    <bean class="org.apache.camel.component.undertow.UndertowComponent" id="undertow">
    <property name="hostOptions" ref="undertowHostOptions"/>
    </bean>
    <bean
    class="org.apache.camel.component.undertow.UndertowHostOptions" id="undertowHostOptions">
    <property name="http2Enabled" value="true"/>
    </bean>
    </beans>

    5. Point to note above http2Enabled is set to true for UndertowHostOptions class, by default it is set to false. This UndertowHostOptions is then referred to UndertowComponent, which is then used in camel route.
    6. We can use camel-maven-plugin in pom.xml then we can run this using maven command mvn camel:run.

    <plugin>
    <groupId&>org.apache.camel</groupId>
    <artifactId>camel-maven-plugin</artifactId>
    <version>${camel.version}</version>
    <configuration>
    <fileApplicationContextUri>src/main/resources/META-INF/spring/camel-context.xml</fileApplicationContextUri>
    </configuration>
    </plugin>

    7. Once successfully run, this should expose an http service at http://localhost:7766/foo/bar.
    8. We can test this using curl and nghttp commands from linux terminal. I used Fedora 26 where curl command with http2 support was available. For RHEL7, I used nghttp utility to test the http2 connection.
    9. Using curl command.

    [csp@dhcppc1 undertow-camel-testing]$ curl -v --http2 http://localhost:7766/foo/bar
    * Trying ::1...
    * TCP_NODELAY set
    * connect to ::1 port 7766 failed: Connection refused
    * Trying 127.0.0.1...
    * TCP_NODELAY set
    * Connected to localhost (127.0.0.1) port 7766 (#0)
    > GET /foo/bar HTTP/1.1
    > Host: localhost:7766
    > User-Agent: curl/7.53.1
    > Accept: */*
    > Connection: Upgrade, HTTP2-Settings
    > Upgrade: h2c
    > HTTP2-Settings: AAMAAABkAARAAAAAAAIAAAAA
    > 
    < HTTP/1.1 101 Switching Protocols
    < Connection: Upgrade
    < Upgrade: h2c
    < Date: Sun, 10 Dec 2017 08:43:58 GMT
    * Received 101
    * Using HTTP2, server supports multi-use
    * Connection state changed (HTTP/2 confirmed)
    * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
    * Connection state changed (MAX_CONCURRENT_STREAMS updated)!
    < HTTP/2 200 
    < accept: */*
    < http2-settings: AAMAAABkAARAAAAAAAIAAAAA
    < breadcrumbid: ID-dhcppc1-1512886066149-0-25
    < content-length: 16
    < user-agent: curl/7.53.1
    < date: Sun, 10 Dec 2017 08:43:58 GMT
    < 
    * Connection #0 to host localhost left intact
    Sending Response

    10. Using nghttp command.

    cpandey@cpandey camel-undertow]$ nghttp -v http://localhost:7766/foo/bar
    [ERROR] Could not connect to the address ::1
    Trying next address 127.0.0.1
    [  0.000] Connected
    [  0.000] send SETTINGS frame <length=12, flags=0x00, stream_id=0>
              (niv=2)
              [SETTINGS_MAX_CONCURRENT_STREAMS(0x03):100]
              [SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
    [  0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=3>
              (dep_stream_id=0, weight=201, exclusive=0)
    [  0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=5>
              (dep_stream_id=0, weight=101, exclusive=0)
    [  0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=7>
              (dep_stream_id=0, weight=1, exclusive=0)
    [  0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=9>
              (dep_stream_id=7, weight=1, exclusive=0)
    [  0.000] send PRIORITY frame <length=5, flags=0x00, stream_id=11>
              (dep_stream_id=3, weight=1, exclusive=0)
    [  0.000] send HEADERS frame <length=45, flags=0x25, stream_id=13>
              ; END_STREAM | END_HEADERS | PRIORITY
              (padlen=0, dep_stream_id=11, weight=16, exclusive=0)
              ; Open new stream
              :method: GET
              :path: /foo/bar
              :scheme: http
              :authority: localhost:7766
              accept: */*
              accept-encoding: gzip, deflate
              user-agent: nghttp2/1.21.1
    [  0.001] recv SETTINGS frame <length=18, flags=0x00, stream_id=0>
              [SETTINGS_HEADER_TABLE_SIZE(0x01):4096]
              [SETTINGS_MAX_FRAME_SIZE(0x05):16384]
              [SETTINGS_INITIAL_WINDOW_SIZE(0x04):65535]
    [  0.001] send SETTINGS frame <length=0, flags=0x01, stream_id=0>
              ; ACK
              (niv=0)
    [  0.001] recv SETTINGS frame <length=0, flags=0x01, stream_id=0>
              ; ACK
              (niv=0)
    [  0.003] recv (stream_id=13) :status: 200
    [  0.003] recv (stream_id=13) accept: */*
    [  0.003] recv (stream_id=13) accept-encoding: gzip, deflate
    [  0.003] recv (stream_id=13) breadcrumbid: ID-cpandey-pnq-csb-1512577017865-0-3
    [  0.003] recv (stream_id=13, sensitive) content-length: 16
    [  0.003] recv (stream_id=13) user-agent: nghttp2/1.21.1
    [  0.003] recv (stream_id=13, sensitive) date: Wed, 06 Dec 2017 17:11:51 GMT
    [  0.003] recv HEADERS frame <length=88, flags=0x04, stream_id=13>
              ; END_HEADERS
              (padlen=0)
              ; First response header
    Sending Response[  0.003] recv DATA frame <length=16, flags=0x01, stream_id=13>
              ; END_STREAM
    [  0.003] send GOAWAY frame <length=8, flags=0x00, stream_id=0>
              (last_stream_id=0, error_code=NO_ERROR(0x00), opaque_data(0)=[])

    1. http://undertow.io/blog/2015/04/27/An-in-depth-overview-of-HTTP2.html
    2. https://developers.google.com/web/fundamentals/performance/http2/


    Whether you are new to Containers or have experience, downloading this cheat sheet can assist you when encountering tasks you haven’t done lately.

    Last updated: November 9, 2023

    Recent Posts

    • A day in the life of an NVIDIA H100 on Red Hat OpenShift 5

    • Migrate BuildConfigs to builds for Red Hat OpenShift with one plug-in install

    • Run Red Hat Enterprise Linux CoreOS on NVIDIA BlueField DPUs

    • Agent harness engineering: Separating model capabilities from enforcement

    • What's new for developers in Red Hat Enterprise Linux 10.3 and 9.9

    Red Hat Developers logo

    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
    Ask AI