Co-author: Siddhesh Prabhu
Integrating enterprise solutions is often a daunting challenge for large organizations, especially those managing a multitude of software applications and microservices. As these systems proliferate, they develop complex communication patterns and employ diverse transports such as Hypertext Transfer Protocol (HTTP), Java Message Service (JMS) queues, and RESTful application programming interfaces (APIs). The rapid advancements in cloud technology and microservices architecture further complicate the landscape, making integration both critical and increasingly complex. However, with the right tools, these challenges can become opportunities.
This is where Red Hat build of Apache Camel for Spring Boot shines, offering a powerful yet simplified approach to enterprise integration with efficiency. Red Hat build of Apache Camel for Spring Boot is a powerful combination of the Apache Camel integration framework and the Spring Boot application framework, specifically tailored for building scalable and robust enterprise integration solutions.
Red Hat build of Apache Camel for Spring Boot streamlines the integration of complex systems by simplifying the management of diverse data formats, protocols, and communication patterns. The framework is now available for the IBM Power architecture (ppc64le), enabling enterprises to leverage the performance and security benefits of this powerful platform.
How can we simplify solution integration with Red Hat build of Apache Camel for Spring Boot on IBM Power?
Deploying Apache Camel for Spring Boot on the IBM Power platform enables organizations to respond swiftly to application and microservice needs.
- Red Hat build of Apache Camel for Spring Boot adheres to best practices, ensuring your integrations are portable, scalable, and secure. It uses industry-proven patterns to streamline communication across different systems.
- Using a rich set of predefined Enterprise Integration Patterns with Apache Camel, you can simplify the development of complex integrations by providing ready-made solutions for common integration challenges.
- IBM Power platform advantages:
- Performance: The IBM ppc64le architecture enhances application and microservice performance, offering quick responses to dynamic business needs.
- Security: It ensures secure data movement and transformation, thereby safeguarding sensitive information.
- Efficient data transformation: Utilize the platform's capabilities, including Matrix Math Acceleration, for fast and efficient data processing and transformation.
- Apache Camel is the leading framework in this space that perfectly suits complex enterprise integrations. It offers a modular and flexible architecture and supports over 200 protocols and data formats, making it the go-to option for integrating diverse systems seamlessly.
Integrating Red Hat build of Apache Camel for Spring Boot on the IBM Power platform allows organizations to simplify their integration processes, boost performance, and enhance data security, leveraging the robust capabilities of Apache Camel.
What is Apache Camel?
Apache Camel is an open-source integration framework that simplifies system integration by providing a domain-specific language for defining integration routes and a rich set of pre-built components. Inspired by the "Enterprise Integration Patterns" book by Gregor Hohpe and Bobby Woolf, Camel offers a set of patterns that facilitate the design and implementation of integration solutions.
Apache Camel
Why Apache Camel?
Apache Camel is lean, lightweight, and extensible, making it a popular choice for integrating complex systems.
Key features:
- Component architecture: Apache Camel provides a modular architecture with components like the Kafka component, which allows seamless interaction with a Kafka cluster.
- Extensive protocol and format support: Apache Camel supports over 200 protocols and data formats, with more than 300 converters available, making it highly versatile for enterprise needs.
- Enterprise Integration Patterns: Provides reusable patterns for common integration tasks like message routing, transformation, and mediation.
- Portability and expandability: Apache Camel ensures that the integrations are portable and easily expandable, crucial for adapting to evolving business requirements.
- Security measures: The framework follows best practices to secure data movement and transformation, ensuring that the enterprise data remains protected.
What is Spring Boot?
Spring Boot is a framework designed to simplify the development of Spring-based applications. It provides a set of conventions and out-of-the-box functionality to streamline the setup and development of new applications.
Spring Boot
Red Hat build of Apache Camel for Spring Boot
The integration of Apache Camel with Spring Boot leverages the strengths of both frameworks. Spring Boot provides a robust and easy-to-use environment for deploying microservices, while Apache Camel offers comprehensive integration capabilities. This combination allows developers to build microservices that can efficiently integrate with other systems, transform data, and route messages with minimal boilerplate code.
Key Benefits:
- Simplified configuration: Spring Boot's auto-configuration feature reduces the need for manual configuration, streamlining the setup of Apache Camel routes and components.
- Scalability: Spring Boot’s ability to create standalone applications complements Apache Camel’s extensive integration capabilities, providing a scalable solution for enterprise integration.
- Security and Performance: Spring Boot's production-ready features and Apache Camel's efficient processing capabilities enables applications to achieve high performance and secure data handling.
Apache Camel with Spring Boot
Install and configure Red Hat build of Apache Camel for Spring Boot on OpenShift cluster for IBM Power
Prerequisites
Before proceeding, ensure you are familiar with the following concepts:
- Apache Maven
- Java
- Spring Boot
- Apache Camel
- Red Hat OpenShift
System requirements:
Note: You can use package installer such as “yum” directly if using Red Hat Enterprise Linux distros for installation.
Steps for deploying a simple Apache Camel Spring Boot application on OpenShift:
- Set up a Spring Boot project.
Perform the following steps to setup a Spring Boot project:
- Create a new Spring Boot project using Spring Initializr.
Use the Spring Initializr to create a new Spring Boot project with dependencies for Spring Web and Spring Boot Starter Camel. This tool generates a project template with various configurations.
Important note: Ensure to modify RedHat and Apache Camel related dependencies in the template to suit your environment.
Figure 1. Spring initializr project template.
- Generate a starter project using Maven.
Generate the Maven starter project based on its type. Starter project is a convenient way to generate a Spring Boot project with the necessary dependencies. An archetype is a template project used to create new projects.
Run the following command in your terminal to generate a Maven starter project for Camel Spring Boot:
mvn archetype:generate -DarchetypeGroupId=org.apache.camel.archetypes -DarchetypeArtifactId=camel-archetype-spring-boot -DarchetypeVersion= 4.4.0.redhat-00025 -DgroupId=com.redhat -DartifactId=csb-app -Dversion=1.0-SNAPSHOT -DinteractiveMode=false
Explanation of the parameters:
DarchetypeGroupId: Specifies the group ID of the Spring Boot archetype.
DarchetypeArtifactId: Specifies the artifact ID of the Spring Boot archetype.
DarchetypeVersion: Specifies the version of the Spring Boot archetype.
DgroupId: Specifies the group ID for your project.
DartifactId: Specifies the project's artifact ID (your projects name).
Dversion: Specifies the project's version.
DinteractiveMode=false: Runs the archetype generation in non-interactive mode.
- Add Apache Camel dependencies.
Add the necessary Apache Camel dependencies to your `pom.xml` file. This usually involves ensuring your `pom.xml` has the necessary plugins and configuration for deploying on OpenShift.
Sample dependencies:
- Camel-spring-boot-starter dependency for developing Spring Boot applications using starters.
<dependency>
<groupId>com.redhat.camel.springboot.platform</groupId>
<artifactId>camel-spring-boot-bom</artifactId>
<version>4.4.0.redhat-00025</version>
<type>pom</type>
</dependency>
- openshift-maven-plugins for OpenShift dependency to deploy applications on OpenShift cluster.
<profiles>
<profile>
<id>openshift</id>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jkube</groupId>
<artifactId>openshift-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>resource</goal>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
- Create an Apache Camel route.
Define a simple Camel route in your Spring Boot application, using the following code. This route triggers every second, sets the message body to "Hello, World!" and logs it.
import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;
@Component
public class MyCamelRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
from("timer:hello?period=1000")
.setBody().constant("Hello, World!")
.to("log:info");
}
}
- Deploy your application.
Use the following Maven command to clean your project and deploy it to OpenShift. -Popenshift
profile is used to enable the OpenShift deployment configuration. Ensure your project is configured correctly to use this profile by using the command oc project <project-name>
mvn clean -DskipTests oc:deploy –Popenshift
Note: The mvn clean
command attempts to clean the files and directories generated by Maven during its build. It clears out the existing classes that you compiled from last compile.
- Verify deployment and status of Apache Camel for Spring Boot application on OpenShift.
After the deployment, verify that your application is running on OpenShift using the OpenShift web console or the oc
CLI.
Use the following commands to view your application pods and also to verify the status of pods on CLI:
# oc get pods
NAME READY STATUS RESTARTS AGE
csb-app-1-bs75b 1/1 Running 0 107m
csb-app-1-deploy 0/1 Completed 0 107m
csb-app-s2i-1-build 0/1 Completed 0 108m
# oc get service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
csb-app ClusterIP 172.30.234.210 <none> 8080/TCP 107m
In the Red Hat OpenShift Web Console, navigate to your project where the Camel application is deployed. Go to the Workloads section. Verify the status of the pods to ensure the application pod is in a Running state.
Figure 2. CSB pods from OCP web console
Here,
csb-app-xxx
: Actual pod on which application is running.
csb-app-deploy
: Pod used to deploy application pod csb-app-xxx.
csb-app-s2i
: Pod for creating source-to-image and pushing to image registry.
In the Red Hat OpenShift Web Console, navigate to the Builds section and verify that the required build image is present.
Figure 3. Builds section on OCP Web Console
In the Builds section, locate the Image Stream containing the application image and verify that the image has been pushed to the default OpenShift Registry by verifying its details.
Figure 4. Builds ImageStreams on OCP Web Console
Figure 5. OpenShift image repository containing application image
Verify the application pod logs to verify that the Spring Boot application is running and displaying the expected Hello World message.
Figure 6. Logs from application pod
Conclusion
Red Hat build of Camel for Spring Boot, combined with the robust capabilities of the IBM Power platform, offers a powerful solution for integrating enterprise applications and microservices. By adhering to best practices and enterprise integration patterns, organizations can achieve seamless, secure, and scalable integrations. Apache Camel's extensive support for protocols and formats, along with its lightweight and extensible nature, makes it the best framework for addressing the complexities of modern enterprise integration. Leverage the power of Red Hat build of Camel for Spring Boot on IBM Power to enhance your enterprise integration efforts today.
Acknowledgements:
The following team members contributed to the Red Hat build of Apache Camel for Spring Boot for Power:
- Prasanna Marathe
- Balavva Mirji
- Vaibhav Nazare
- Siddhesh Prabhu
- Shreya Kajbaje
Upcoming:
Stay tuned for our upcoming blogs in this series where we demonstrate Camel Spring Boot examples with components such as Advanced Message Queuing Protocol (AMQP) and Kafka:
- Red Hat build of Camel for Spring Boot with AMQP.
- Red Hat build of Camel for Spring Boot with Kafka.