Chapter 3. Defining Camel routes
In Red Hat build of Apache Camel for Quarkus, you can define Camel routes using the following languages:
3.1. Java DSL Copy linkLink copied to clipboard!
Extending org.apache.camel.builder.RouteBuilder and using the fluent builder methods available there is the most common way of defining Camel Routes. Here is a simple example of a route using the timer component:
3.2. Endpoint DSL Copy linkLink copied to clipboard!
Since Camel 3.0, you can use fluent builders also for defining Camel endpoints. The following is equivalent with the previous example:
Builder methods for all Camel components are available via camel-quarkus-core, but you still need to add the given component’s extension as a dependency for the route to work properly. In case of the above example, it would be camel-quarkus-timer.
3.3. XML IO DSL Copy linkLink copied to clipboard!
In order to configure Camel routes, rests or templates in XML, you must add a Camel XML parser dependency to the classpath. Since Camel Quarkus 1.8.0, link:https://access.redhat.com/documentation/en-us/red_hat_build_of_apache_camel/4.0/html-single/red_hat_build_of_apache_camel_for_quarkus_reference/ #extensions-xml-io-dsl[camel-quarkus-xml-io-dsl] is the best choice.
With Camel Main, you can set a property that points to the location of resources XML files such as routes, REST DSL and Route templates:
camel.main.routes-include-pattern = routes/routes.xml, file:src/main/routes/rests.xml, file:src/main/rests/route-template.xml
camel.main.routes-include-pattern = routes/routes.xml, file:src/main/routes/rests.xml, file:src/main/rests/route-template.xml
Path globbing like camel.main.routes-include-pattern = *./routes.xml currently does not work in native mode.
Route
When using XML routes with beans, it is sometime needed to refer to class name, for instance beanType=org.apache.SomeClass. In such cases, it might be needed to register the class for reflection in native mode. Refer to the Native mode section for more information.
Spring XML with <beans> or Blueprint XML with <blueprint> elements are not supported.
The route XML should be in the simplified version like:
Rest DSL
Route Templates
3.4. YAML DSL Copy linkLink copied to clipboard!
To configure routes with YAML, you must add the camel-quarkus-yaml-dsl dependency to the classpath.
With Camel Main, you can set a property that points to the location of YAML files containing routes, REST DSL and Route templates definitions:
camel.main.routes-include-pattern = routes/routes.yaml, routes/rests.yaml, rests/route-template.yaml
camel.main.routes-include-pattern = routes/routes.yaml, routes/rests.yaml, rests/route-template.yaml
Route
Rest DSL
Route Templates