DEV Community


Posted on

Apache Camel 4.x + Spring Boot 3.x + RabbitMq + IbmMq

What is Aapche Camel?

Camel is an Open Source integration framework that empowers you to quickly and easily integrate various systems consuming or producing data.

In this article, we are going to read data from IbmMq(producer) and send it to rabbitMq (consumer). I am going to run RabbitMq and IbmMq locally using Docker desktop. I will also share the docker command as well to run RabbitMq and IbmMq containers.


  1. JDK — 17+
  2. Docker Desktop

Let’s start by executing the docker command assuming you have a docker desktop running on your local machine.


docker command
docker run - env LICENSE=accept - env MQ_QMGR_NAME=QM1 - publish 1414:1414 - publish 9443:9443 - detach ibmcom/mq

Console url : https://localhost:9443/ibmmq/console
UserId/Password : admin/passw0rd

RabbitMq docker command

docker run -it -p 5672:5672 --hostname my-rabbit --name some-rabbit rabbitmq:3

Console Url : http://localhost:15672
UserId/Password : guest/guest

Spring Boot Application

Let’s create a Spring Boot Application

You can create Spring Boot Application from spring initializr.

Image description

Make sure you select maven, Spring Boot version 3.2.0 and click on Generate.
Once the project is downloaded you can open the project in any IDE of your choice. In my case, I am using Intellij.
Up until now, we have not added any dependency in pom.xml.
Let’s start by adding spring boot dependency in the dependencies section in pom.xml.

Enter fullscreen mode Exit fullscreen mode

Apache Camel Dependency

Enter fullscreen mode Exit fullscreen mode

RabbitMq Dependency

Enter fullscreen mode Exit fullscreen mode

IbmMq Dependency

Enter fullscreen mode Exit fullscreen mode

All the required dependencies added, let’s add rabbitmq and ibmmq configuration in the file.

camel.springboot.main-run-controller=true = MyCamel
# RabbitMQ Configuration

# IBM-MQ Configuration
Enter fullscreen mode Exit fullscreen mode

Almost at the last step, create a class which extends RouterBuilder. Override method configure and add routes.

import org.apache.camel.builder.RouteBuilder;
import org.springframework.stereotype.Component;

public class RouteService extends RouteBuilder {
    public void configure() throws Exception {

        // first route
                .transform(simple("Random number ${random(0,100)}"))

        // second route
                .log("Message Posted in RabbitMq")

        // third route
                .log("Data from rabbitmq: ${body}");
Enter fullscreen mode Exit fullscreen mode

In the above code, we have added the first route which triggers every 5 seconds and generates a random number between 0 to 100 and inserts that data in IBM MQ.

In the second route, we are reading data from ibmmq which was pushed in route1 and adding that data as it is in rabbitmq.

To verify if data was being posted successfully in rabbitmq we have introduced a third route, which reads data from rabbitmq and logs it.

You can also verify by logging into the rabbitmq console.


Run spring boot application using IDE or using maven command mvn spring-boot:run and monitor logs.

repo link:

Thank you for your attention! Happy Learning!

Top comments (0)