Building a Camel route to remote ActiveMQ

In this tutorial, we will learn how to send and consume messages to Artemis MQ (Message Queue) using Camel Route. Artemis MQ is a high-performance messaging system that supports the Java Message Service (JMS) API. Camel is an open-source integration framework that provides a powerful routing and mediation engine.


Before we begin, make sure you have the following prerequisites installed:

  • Apache Artemis MQ
  • Apache Camel
  • Java Development Kit (JDK)
  • Integrated Development Environment (IDE) of your choice

Step 1: Set Up the Project

  1. Create a new Java project in your IDE.
  2. Add the necessary Apache Camel and Artemis MQ dependencies to your project’s pom.xml file:


Step 2: Start Artemis MQ

To run our example, you can either download Artemis MQ from

Alternatively you can run ArtemisMQ as Container Image:

docker run --rm -e AMQ_USER=admin -e AMQ_PASSWORD=admin -p 61616:61616 --name artemis

To learn more about running Artemis MQ in a Container we recommend checking this article: How to run Artemis MQ as Docker Image

Step 3: Define Camel Routes

Create a new Java class, such as JMSDemo, which defines the following Camel routes:

public class JMSDemo {
    public static void main(String[] args) throws Exception {
        CamelContext context = new DefaultCamelContext();
        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://");
        JmsComponent jms = new JmsComponent();

        context.addComponent("jms", jms);
            new RouteBuilder() {
              public void configure() {
                    .setBody(simple("Message at ${date:now:yyyy-MM-dd HH:mm:ss}"))
                    .setHeader("JMSMessageID", constant(UUID.randomUUID().toString()))
                    .setHeader("JMSReplyTo", constant("client1"))


                        new Processor(){

                            public void process(Exchange exchange) throws Exception {
                                Map<String, Object> headers = exchange.getIn().getHeaders();

                                // Print all headers
                                for (Map.Entry<String, Object> entry : headers.entrySet()) {
                                    String headerName = entry.getKey();
                                    Object headerValue = entry.getValue();
                                    System.out.println(headerName + ": " + headerValue);
                    .log("Received: ${body}");


Firstly, we are setting up an ActiveMQConnectionFactory with the settings to connect to the Remote Artemis MQ at the address tcp://

Then, we are sending messages to the JMS Destination jms:queue:activemq/queue/TestQueue through a Timer Component.

Finally, we are consuming messages from jms:queue:activemq/queue/TestQueue and attaching a Processor to the Message Exchange. This Processor demonstrates how to process the Messaging Headers of the messages. As you can see, when producing Messages we are setting the JMSMessageID and the JMSReplyTo so that this information shows in the Processor.

Running the Camel Route

Then, execute the Camel main class and verify that JMS Messages are produced and consumed and that Headers display on the console:

artemis mq camel jms integration tutorial


In conclusion, this tutorial has provided a step-by-step guide to building a Camel route for sending and consuming messages to Artemis MQ. By leveraging the power of Apache Camel and Artemis MQ, developers can easily integrate messaging capabilities into their applications.

Throughout this tutorial, we covered the essential steps, including setting up the project, configuring the Artemis MQ connection, defining Camel routes, and sending/consuming messages. By following these steps, you can establish a seamless communication channel between your application and the messaging system.

Found the article helpful? if so please follow us on Socials
Twitter Icon       Facebook Icon       LinkedIn Icon       Mastodon Icon