Running multiple ActiveMQ instances on one machine

A few weeks ago I started making use of Apache ActiveMQ again as the JMS provider with my Mule ESB solution. Since it had been a few years that I used ActiveMQ I thought it would be nice to check out some of the (new) features like the failover transport and other clustering features. To be able to test these last things I needed multiple installations of ActiveMQ on my machine. Luckily this isn’t very hard to accomplish, although the documentation on this on the ActiveMQ site is quite minimal.
The first step is to download and unzip the ActiveMQ package, which I did at ~/develop/apache-activemq-5.8.0.

To create the instances I go to the activeMQ home directory and use the ‘create’ command like this:

cd develop/apache-activemq-5.8.0/
./bin/activemq create instanceA
./bin/activemq create instanceB

Now if you do a ‘ls -l’ you will see that there are two subdirectories created, ‘instanceA’ and ‘instanceB’. Since both instances will make use of the default ports we have to modify the config for the second instance. Go to the directory ‘develop/apache-activemq-5.8.0/instanceB/conf’ and open the file ‘jetty.xml’ to make the webconsole available at port ‘8162’ by modifying the following line:

<bean id="Connector" class="org.eclipse.jetty.server.nio.SelectChannelConnector">
  <property name="port" value="8162" />

Next open the file ‘activemq.xml’ in the same directory and modify the following part:

  <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
  <transportConnector name="openwire" uri="tcp://"/>
  <transportConnector name="amqp" uri="amqp://"/>

That’s it! Make sure both files are saved and start the first instance with:
cd ~/develop/apache-activemq-5.8.0/instanceA/bin
./instanceA console

Open up a new console and run the commands:
cd /Users/pascal/develop/apache-activemq-5.8.0/instanceB/bin
./instanceB console

Screenshot 2014-01-18 08.52.39
Now you have two instances running next to each other and can start testing the ‘advanced’ functions of ActiveMQ.

When using ActiveMQ 5.10 you might run into an error (Thanks Alejandro for mentioning this):

using ActiveMq 5.10 I’m hitting the same issue the other person reported (can’t lock file). There are a couple different steps needed:
1) the generated instanceX\bin\instanceX.bat files are incomplete, I had to add

set ACTIVEMQ_CONF=”/instanceB/conf”
set ACTIVEMQ_DATA=”/instanceB/data”

2) there are a few more connectors to update in activemq.xml (stomp, mqtt and ws). I had to specify different ports there

3) to start, now use “instanceX\bin\instanceX.bat start”

==End of update==


About Pascal Alma

Pascal is a senior IT consultant and has been working in IT since 1997. He is monitoring the latest development in new technologies (Mobile, Cloud, Big Data) closely and particularly interested in Java open source tool stacks, cloud related technologies like AWS and mobile development like building iOS apps with Swift. Specialties: Java/JEE/Spring Amazon AWS API/REST Big Data Continuous Delivery Swift/iOS
This entry was posted in ActiveMQ and tagged . Bookmark the permalink.

7 Responses to Running multiple ActiveMQ instances on one machine

  1. suja says:

    I wasn’t able to create 2 seperate instance on same machine on comparing my log with yours i found that below values differ

    ACTIVEMQ_HOME: C:\apache-activemq-5.9.0
    ACTIVEMQ_BASE: C:\apache-activemq-5.9.0\instance1
    ACTIVEMQ_CONF: C:\apache-activemq-5.9.0\conf
    ACTIVEMQ_DATA: C:\apache-activemq-5.9.0\data

    Could you please let me know as what went wrong.

    • Pascal Alma says:

      But why weren’t you able to run the two instances? Do you get an error message?

      • suja says:

        On running the instance2 after editing the xml’s below is the o/p

        ACTIVEMQ_BASE: C:\apache-activemq-5.9.0\cluster\broker-2
        ACTIVEMQ_CONF: C:\apache-activemq-5.9.0\conf
        ACTIVEMQ_DATA: C:\apache-activemq-5.9.0\data

        INFO | Database C:\apache-activemq-5.9.0\data\kahadb\lock is locked… waiting
        10 seconds for the database to be unlocked. Reason: File ‘C
        :\apache-activemq-5.9.0\data\kahadb\lock’ could not be locked.

        and im not able to access seperate admain pages for each instance.
        http://localhost:8161/admin/index.jsp. shows broker’s name as loacal host

  2. Pascal Alma says:

    If correct you should have the following directory structure:



    Based on the error message I think you run the ‘default’ install that is under:

    Please can you check if you have the corresponding directory structures?

    • suja says:

      My directory structures are the same

      • suja says:

        I got the seperate instances by editing the respective .bat files, included the following


      • Pascal Alma says:

        But %ACTIVEMQ_BASE% is an environment variable that is the same for both instances. That’s why it is not working because both instances will then be still looking into the same folder. Why do you have to edit the bat files?

Comments are closed.