Open Source Development

Open Source Development

Connect, learn, share, and engage with IBM Power.

 View Only

Migrate Red Hat Fuse 7 to Camel Extension of Quarkus

By Shreya Kajbaje posted 25 days ago

  

Red Hat Fuse 7 is cloud-native, distributed solution to easily develop, deploy and scale integration applications. Although Red Hat Fuse 7 has reached the end of maintenance support on June 30, 2024 (refer article),customers who still want to continue receiving support for Fuse 7 must purchase an Extended Life Cycle Support (ELS) subscription. To receive comprehensive support, bug fixes and Common Vulnerabilities and Exposures (CVE) fixes, Red Hat recommends migrating the applications running on Fuse 7 to Red Hat build of Apache Camel. The migration gives an opportunity to move from traditional server architectures to Quarkus or Spring Boot Microservices architecture.

In this blog, we walk you through an example migration and provide a reference guide for transitioning applications from Red Hat Fuse to Apache Camel. Apache Camel Extension of Quarkus (CEQ) is a Camel runtime which allows to run integration processes with super low memory usage, fast startup, and outstanding performance. Quarkus is a Java framework for Kubernetes deployment.

Migrating from Red Hat Fuse 7 to Camel Extension of Quarkus offers several benefits, as CEQ is optimized for cloud-native and containerized environments. Some of the key advantages include:

  • Performance and efficiency: CEQ leverages properties such as fast startup times and low memory footprint, which makes it well-suited for cloud environments and microservices architectures. It uses less memory and takes very less time to start compared to traditional Java applications, such as Red Hat Fuse 7.
  • Integration with the latest ecosystem: With CEQ, it is easier to integrate with the latest cloud-native technologies, such as Kubernetes, Red Hat OpenShift, and Kafka, along with various other cloud-based services and protocols.
  • Simpler configuration and management: CEQ offers a more streamlined configuration approach with properties that are easy to understand and customize. Also, it simplifies dependency management and provides a more unified approach to handle configurations, which are often more complex in older versions of Camel, such as Fuse.

Migrating a Red Hat Fuse 7 application to CEQ

As explained earlier, the migration of Red Hat Fuse 7 applications to CEQ is inevitable. Let us see an example for migrating such an application to CEQ.

Note: For migrating a Java Domain Specific Language (DSL) route definition from Fuse application to CEQ, copy your existing route definition directly to your Red Hat build of the Apache Camel for Quarkus application and add the necessary dependencies to your Red Hat build of the Apache Camel for Quarkus pom.xml file.

In this example, we have migrated a content-based route definition from a Red Hat Fuse 7 application to a new CEQ application. Perform the following steps to complete the migration process.

Step 1. Set up a Camel Quarkus project

  1. Go to code.quarkus.redhat.com and select all the extensions required for your project. For this project, we have selected the following extensions:
    • camel-quarkus-file
    • camel-quarkus-xpath

    Click Generate your application.

  2. Extract the ZIP file (generated in step 1) and navigate to the project file using the following command.
    $ cd <directory_name>
  3. Create a file named CsvGenerateRoutes.java in the src/main/java/org/acme/ subfolder. This file contains all required routes for the application.
  4. Add the route definition from Fuse application to the CsvGenerateRoutes.java file.
  5. Compile this CEQ application using following command:
    mvn clean compile quarkus:dev

Step 2. Add additional Camel extensions

In this example, we have added camel-quarkus-bindy component for the purpose of application dependency in the pom.xml file as shown below.

<dependency>
            <groupId>org.apache.camel.quarkus</groupId>
            <artifactId>camel-quarkus-bindy</artifactId>
        </dependency>

Step 3. Rewrite Camel routes

Red Hat Fuse 7 uses Blueprint or Spring XML to define routes, whereas Camel Quarkus relies on Java DSL or YAML for route definitions.

Here is example of routes defined in Red Hat Fuse 7 (Blueprint or Spring XML route example):

xml
   <route>
       <from uri="jms:queue:myQueue"/>
       <to uri="log:myLogger"/>
   </route>

- Here is example to rewrite the same route in Camel Quarkus (Java DSL route example):

   java
   @ApplicationScoped
   public class MyRoute extends RouteBuilder {
       @Override
       public void configure() {
           from("jms:queue:myQueue")
               .to("log:myLogger");
       }
   }

Next, migrate the following route in Java DSL.

Step 4. Update dependencies

In Red Hat Fuse 7, you might have dependencies on specific Fuse libraries or features. For CEQ, you need to use Quarkus extensions, many of which are based on the same Camel components.

In Red Hat Fuse, you would typically use dependencies such as `fuse-camel-ftp`, `fuse-camel-jms`, `fuse-camel-kafka`, and so on. Whereas for CEQ, you must use the dependencies that corresponds to the Camel Quarkus extensions.

For example:

  • camel-quarkus-jms
  • camel-quarkus-kafka
  • camel-quarkus-mongodb
  • camel-quarkus-ftp

You may encounter multiple compilation issues during the migration process. Refer to the following error sample that we encountered while migrating the FTP route for this example.

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /root/Shreya/ftp/code-with-quarkus/src/main/java/org/acme/CsvGenerateRoute.java:[3,32] package javax.enterprise.context does not exist
[ERROR] /root/Shreya/ftp/code-with-quarkus/src/main/java/org/acme/CsvGenerateRoute.java:[7,2] cannot find symbol
  symbol: class ApplicationScoped
[ERROR] /root/Shreya/ftp/code-with-quarkus/src/main/java/org/acme/Customer.java:[1,52] package org.apache.camel.dataformat.bindy.annotation does not exist
[ERROR] /root/Shreya/ftp/code-with-quarkus/src/main/java/org/acme/Customer.java:[5,6] cannot find symbol
  symbol:   class DataField
  location: class Customer
[ERROR] /root/Shreya/ftp/code-with-quarkus/src/main/java/org/acme/Customer.java:[8,6] cannot find symbol
  symbol:   class DataField
  location: class Customer
[ERROR] /root/Shreya/ftp/code-with-quarkus/src/main/java/org/acme/Customer.java:[11,6] cannot find symbol
  symbol:   class DataField
  location: class Customer

In the above case, import javax.enterprise.context.ApplicationScoped [an annotation in the Context and Dependency Injection (CDI) framework] that was used in the Fuse code is not available in CEQ.

As shown in the above error sample, such compilation errors commonly occur when a class is not found or an import statement is not correct (as the name of the imported class or the function in CEQ is not the same as the one used in Fuse). You can verify this in the CEQ latest version documentation and make related changes in code.

Step 5. Rework configuration

In Fuse, configurations are often managed through the Fuse Management Console or the Spring and Blueprint properties. In CEQ, configuration is generally done using the application.properties or application.yml files.

In this example, we have used the camel-context.xml file for configuration. In this file, all the configurations such as starting point of trigger, location of trigger that is generated, details of transferred files, and other major configurations are defined.

While migrating from Fuse, these configurations need to be reworked to configure correctly in the CEQ environment.

Step 6. Test and debug

After you have rewritten the routes and configured the extensions, perform the following steps to test and debug:

  • Test the routes in isolation to ensure that they work correctly.
  • Use Quarkus Dev mode (`./mvnw compile quarkus:dev`) to enable live reloading and debugging.

Note:

In this blog, we have demonstrated a basic sample application to provide high-level overview of the process involved in transitioning applications and for explaining key considerations such as route re-engineering and components compatibility. However, in reality while migrating from Fuse 7 to Camel Quarkus, you may encounter challenges influenced by the client's application design and complexity.

Summary

Migrating from Red Hat Fuse 7 to Camel Extension of Quarkus gives you access to the latest advancements in performance, cloud-native deployments, and developer productivity. It also helps you to simplify integration management and reduce the infrastructure costs.

0 comments
17 views

Permalink