Published on

Using the Camel Undertow component with the WildFly Camel Subsystem

  • avatar
    James Netherton

A nice addition to the WildFly Camel Subsystem 3.1.0 release is the camel-undertow component.

This is useful for WildFly because we can leverage the existing Undertow HTTP engine and enable Camel to configure HTTP Handlers into it. This gives us the capability to produce and consume HTTP messages.

Standalone Camel Undertow Vs WildFly Camel Undertow

There are some minor differences between configuring Camel Undertow for standalone Camel Vs WildFly Camel in relation to consumer endpoints.

Standalone Camel Undertow lets you do:


This configuration starts an embedded Undertow server on localhost bound to port 7766.

For WildFly Camel, this would not be allowed. Since WildFly is already running an Undertow HTTP engine, it makes sense to reuse this, rather than create a new Undertow instance. This has advantages such as being able to take advantage of WildFly's native security mechanisms, graceful shutdown etc.

Therefore, we are restricted to consuming from the port that has been configured within the WildFly socket-binding configuration (usually 8080).


Undertow consumer

An Undertow HTTP consumer would look like:

public class UndertowConsumerRouteBuilder extends RouteBuilder {

    public void configure() throws Exception {
        .transform(simple("Hello ${}"))

When the Camel application is deployed, you should see a message output to the console logs like:

Add Camel endpoint:

Now you can open a web browser and navigate to You should see a response output as 'Hello James'.

Undertow producer

The producer acts as an HTTP client to make requests to a specified HTTP endpoint. Here's an example that creates your own IP address lookup service by outputting the response from

public class UndertowProducerRouteBuilder extends RouteBuilder {

    public void configure() throws Exception {

Browse to and you should see your IP address.

Undertow with the Camel REST DSL

The Undertow component can also be used with the Camel REST DSL. It's useful to combine this with the camel-swagger-java dependency for endpoint documentation.

public class RESTRouteBuilder extends RouteBuilder {

    public void configure() throws Exception {

        .get("/{name}").description("GET name")
        .post("/{name}").description("POST name")
        .put("/{name}").description("PUT name")
        .delete("/{name}").description("DELETE name")

      from("direct:get").transform(simple("GET ${}"));
      from("direct:post").transform(simple("POST ${}"));
      from("direct:put").transform(simple("PUT ${}"));
      from("direct:delete").transform(simple("PUT ${}"));

You can then use a HTTP client such as cURL to send requests using each of the HTTP verbs that the above example can handle:

curl -v http://localhost:8080/camel/rest/hello/James
curl -v -X POST http://localhost:8080/camel/rest/hello/James
curl -v -X PUT http://localhost:8080/camel/rest/hello/James
curl -v -X DELETE http://localhost:8080/camel/rest/hello/James

To see the swagger markup you can browse to http://localhost:8080/camel/rest/api-doc.


Hopefully this has been a good introduction to the Camel Undertow component on the WildFly Camel Subsystem. Doubtless, it'll continue to evolve and improve.

I'd like to see more Camel components use Undertow as their HTTP engine, as it'd enabled them to better integrate with WildFly. Stay tuned for progress in this area.