Archive for the ‘activemq’ Category

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