Chapter 2. Migrating Camel Routes from Fuse 7 to Camel Extensions for Quarkus (CEQ)
You can define Camel routes in CEQ applications using Java DSL, XML IO DSL, or YAML.
2.1. Java DSL route migration example Copy linkLink copied to clipboard!
To migrate a Java DSL route definition from your Fuse application to CEQ, you can copy your existing route definition directly to your CEQ application and add the necessary dependencies to your CEQ pom.xml file.
In this example, we will migrate a content-based route definition from a Fuse 7 application to a new CEQ application by copying the Java DSL route to a file named Routes.java in your CEQ application.
Procedure
Using the
code.quarkus.redhat.comwebsite, select the extensions required for this example:- camel-quarkus-file
- camel-quarkus-xpath
Navigate to the directory where you extracted the generated project files from the previous step:
cd <directory_name>
$ cd <directory_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Create a file named
Routes.javain thesrc/main/java/org/acme/subfolder. Add the route definition from your Fuse application to the
Routes.java, similar to the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Compile your CEQ application.
mvn clean compile quarkus:dev
mvn clean compile quarkus:devCopy to Clipboard Copied! Toggle word wrap Toggle overflow
This command compiles the project, starts your application, and lets the Quarkus tooling watch for changes in your workspace. Any modifications in your project will automatically take effect in the running application.
2.2. Blueprint XML DSL route migration Copy linkLink copied to clipboard!
To migrate a Blueprint XML route definition from your Fuse application to CEQ, use the camel-quarkus-xml-io-dsl extension and copy your Fuse application route definition directly to your CEQ application. You will then need to add the necessary dependencies to the CEQ pom.xml file and update your CEQ configuration in the application.properties file.
CEQ supports Camel 3, whereas Fuse 7 supports Camel 2. For more information relating to upgrading Camel when you migrate your Red Hat Fuse 7 application to CEQ, see Migrating from Camel 2 to Camel 3.
For more information about using beans in Camel Quarkus, see the CDI and the Camel Bean Component section in the Developing Applications with Camel Extensions for Quarkus guide.
2.2.1. XML-IO-DSL limitations Copy linkLink copied to clipboard!
You can use the camel-quarkus-xml-io-dsl extension to assist with migrating a Blueprint XML route definition to CEQ.
The camel-quarkus-xml-io-dsl extension only supports the following <camelContext> sub-elements:
- routeTemplates
- templatedRoutes
- rests
- routes
- routeConfigurations
As Blueprint XML supports other bean definitions that are not supported by the camel-quarkus-xml-io-dsl extension, you may need to rewrite other bean definitions that are included in your Blueprint XML route definition.
You must define every element (XML IO DSL) in a separate file. For example, this is a simplified example of a Blueprint XML route definition:
You can migrate this Blueprint XML route definition to CEQ using XML IO DSL as defined in the following files:
src/main/resources/routes/camel-rests.xml
src/main/resources/routes/camel-routes.xml
<routes xmlns="http://camel.apache.org/schema/spring">
<route>
<from ..../>
</route>
</routes>
<routes xmlns="http://camel.apache.org/schema/spring">
<route>
<from ..../>
</route>
</routes>
You must use Java DSL to define other elements which are not supported, such as <restConfiguration>. For example, using a route builder defined in a camel-rests.xml file as follows:
src/main/resources/routes/camel-rests.xml
2.2.2. Blueprint XML DSL route migration example Copy linkLink copied to clipboard!
For more information about using the XML IO DSL extension, see the XML IO DSL documentation in the Camel Extensions for Quarkus Reference.
In this example, you are migrating a content-based route definition from a Fuse application to a new CEQ application by copying the Blueprint XML route definition to a file named camel-routes.xml in your CEQ application.
Procedure
Using the
code.quarkus.redhat.comwebsite, select the following extensions for this example:- camel-quarkus-xml-io-dsl
- camel-quarkus-file
- camel-quarkus-xpath
- Select Generate your application to confirm your choices and display the overlay screen with the download link for the archive that contains your generated project.
- Select Download the ZIP to save the archive with the generated project files to your machine.
- Extract the contents of the archive.
Navigate to the directory where you extracted the generated project files from the previous step:
cd <directory_name>
$ cd <directory_name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Create a file named
camel-routes.xmlin thesrc/main/resources/routes/directory. Copy the
<route>element and sub-elements from the followingblueprint-example.xmlexample to thecamel-routes.xmlfile:blueprint-example.xml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow camel-routes.xml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Modify
application.propertiesCamel
# Camel # camel.context.name = camel-quarkus-xml-io-dsl-example camel.main.routes-include-pattern = file:src/main/resources/routes/camel-routes.xmlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Compile your CEQ application.
mvn clean compile quarkus:dev
mvn clean compile quarkus:devCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteThis command compiles the project, starts your application, and lets the Quarkus tooling watch for changes in your workspace. Any modifications in your project will automatically take effect in the running application.