Apache Camel Integration With ActiveMQ
This article covers integration of Apache Camel with ActiveMQ.
Join the DZone community and get the full member experience.Join For Free
This article covers Apache Camel Integration with ActiveMQ.
Apache MQ Setup
We will launch Apache MQ as a Docker container. Run the below command to launch Apache MQ as a Docker container.
Open the ActiveMQ web console at http://localhost:8161. Click on Manage ActiveMQ broker and login using admin as the username and password when prompted for credentials.
A screen like the below opens:
Let's create two Spring Boot Camel microservices,
camel-demo-a will publish the data to the ActiveMQ queue which will be consumed by
pom.xml of both the microservices, add the below dependency:
Configure the broker URL in the
Configuring the ActiveMQ Sender Route in
The route is configured to read from the file and publish it to the ActiveMQ queue:
Configuring the ActiveMQ Receiver Route in
Let's assume that the sender route is publishing a JSON message, which we will unmarshall and use to perform some processing.
pom.xml file of the
camel-demo-b application, add the below dependency:
Creating the Model Class
The route is configured to consume the message from the ActiveMQ queue, so we'll unmarshal it using the Jackson JSON library and do some processing.
camel-demo-a application and place the JSON file in the input folder.
The file will be read and the message will be published to the ActiveMQ queue.
camel-demo-b application. Observe that the route consumes the message from the queue and that it performs JSON unmarshalling as well as further processing.
Opinions expressed by DZone contributors are their own.