Start multiple ActiveMQ brokers in the same server

Posted: February 5, 2014 in activemq, broker, linux, Uncategorized
This turotial explains how to run multiple ActiveMQ brokers within the same machine.
Download ActiveMQ packs from
Below are the minimum commands we required for this set up.
create                   – Creates a runnable broker instance in the specified path.

setup                    –  Create the specified configuration file for this init script

You can view all the available commands by executing  bin/activemq

Step 1: Create broker 1 and 2

cd $active_mq_installation_folder // this is where you extract the apache-activemq-x.x.x.tar.gz
#create a runnable broker called “broker1”
bin/activemq create broker1
# Create the configuration file for the init script of broker1.
bin/activemq setup ~/.activemqrc-instance-broker1
#create a symbolic link
ln -s activemq bin/activemq-instance-broker1
#create the broker2
bin/activemq create broker2
bin/activemq setup ~/.activemqrc-instance-broker2
ln -s activemq bin/activemq-instance-broker2
Step 2: Change ports

grep 16 broker[12]/conf/*.xml

broker1/conf/activemq.xml: <transportConnector name=”openwire” uri=”tcp://;wireFormat.maxFrameSize=104857600″/>
broker1/conf/activemq.xml: <transportConnector name=”stomp” uri=”stomp://;wireFormat.maxFrameSize=104857600″/>
broker1/conf/activemq.xml: <transportConnector name=”ws” uri=”ws://;wireFormat.maxFrameSize=104857600″/>
broker1/conf/jetty.xml: <property name=”port” value=”8161″/>
broker1/conf/jetty.xml: <property name=”port” value=”8162″ />
broker2/conf/activemq.xml: <transportConnector name=”openwire” uri=”tcp://;wireFormat.maxFrameSize=104857600″/>
broker2/conf/activemq.xml: <transportConnector name=”stomp” uri=”stomp://;wireFormat.maxFrameSize=104857600″/>
broker2/conf/activemq.xml: <transportConnector name=”ws” uri=”ws://;wireFormat.maxFrameSize=104857600″/>
broker2/conf/jetty.xml: <property name=”port” value=”8161“/>
broker2/conf/jetty.xml: <property name=”port” value=”8161” />

You can see that both broker1 and broker2 has same configurations. For instance both have the tcp runs on port 61616. This will be a problem when we start the broker2 since broker1 is already running on port 61616.
Also we need to edit the webConsole port(which is by default 8162) in one of the brokers. This is the port the web console runs. You can point to http://localhost:8161 to view the ActiveMQ web console.
So we need to edit either broker1 or broker2 configurations in a way that same port number does not appear in both the brokers.
Start the multiple instances
Start broker 1:
sh broker1/bin/broker1 console
Start broker 2 (in another console):
sh broker2/bin/broker2 console
You may see the logs printing in the console.
Locate your browser to https://localhost:8161 to view the web console. This port (8161) is configured in conf/jetty.xml
  1. David says:

    One note – since v5.11.0 the “setup” parameter sepcified here has been replaced with use of environment variables (see: so an instance specific script wrapper is required.

  2. Adnan says:

    Lets say you start 2 instances A and B. A instance is started first and subsequently B is started and if i need to stop instance B, how do i go about doing it?

    How to stop these instances once they have been started

    • I think you can us ‘ps -ef | grep active’ to filter out activemq processors. ps will show the command used to start the process, ” broker1/bin/broker1 ” for one and ” broker2/bin/broker2 ” for other process. You can get the appropriate process id and use “kill -9” to kill the relevant process.

      You can try out to find if there is any command to stop a broker such as “sh broker2/bin/broker2 stop” which can be used to stop the process.

      Thank you very much for your question, I think my article lacks this part. First method I mentioned is the most naive method I would use. Please reply back if you find a better way so I can add to this article.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s