Christian Posta bio photo

Christian Posta

Field CTO at solo.io, author Istio in Action and Microservices for Java Developers, open-source enthusiast, cloud application development, committer @ Apache, Serverless, Cloud, Integration, Kubernetes, Docker, Istio, Envoy #blogger

Twitter Google+ LinkedIn Github Stackoverflow

So I haven't been blogging as much recently -- just been really busy. But my New Year's resolution is to blog a little more sharing some things I come across frequently, even if it's simple stuff that might help some people out.

So for this entry, I'll show a quick way to start up multiple JBoss A-MQ instances on a single machine. The reason why this question comes up is because JBoss A-MQ includes a little more "enterprise" ready features out of the box than plain old community ActiveMQ. JBoss A-MQ is a production-ready, hardened, version of ActiveMQ, and it's packaged inside Apache Karaf with some other features like the HawtIO console (and more).

What happens when people are trying to simulate more complex deployment scenarios in a lab or development environment, they may not have access to multiple VMs or machines to try out a full real-world deployment. So they may want to install multiple brokers on a single box. This is pretty straight forward, and all you have to do is make sure the default ports don't conflict. NOTE: this is not intended to be a production deployment!!! Don't deploy this way to production!!

You can get pretty wacky and customize each additional A-MQ/Karaf JVM with the Karaf admin commands but if you want to just get something working and want to understand where the port conflicts can be, check this out:

Download JBoss A-MQ

Go to the Red Hat support portal (or JBoss.org) and download the copy of JBoss A-MQ you want to use. Note, the bits are the same from whichever website you download from, but you need a valid subscription to use in any shared environments (anything excluding your development laptop).

For this exercise, we're using JBoss A-MQ 6.1 (filename jboss-a-mq-6.1.0.redhat-379.zip)

Install into two locations

If we want to have two separate JBoss A-MQ brokers, let's start by unpacking into two separate locations:

~> unzip jboss-a-mq-6.1.0.redhat-379.zip -d amq01
~> unzip jboss-a-mq-6.1.0.redhat-379.zip -d amq02

Now in each installation path (eg, ./amq01/jboss-a-mq-6.1.0.redhat-379), which we'll call the broker's BASE directory, find the files in the $BASE/etc folder with the name users.properties. Uncomment the last line in that file so we have an admin user.

Change ports

Last step we need to do is change the ports in the installation for amq02 so they don't conflict.

There are three files we'll need to touch, which are the config PIDs for the services that run in the container.

etc/org.apache.karaf.management.cfg

In this file, edit the following properties:

rmiRegistryPort = 1098  #default is 1099
rmiServerPort = 44445   #default is 44444

Note, those are the changed values. You can change them to whatever you want.

etc/org.apache.karaf.shell.cfg

In this file, edit the following properties:

sshPort = 8102  #default is 8101

etc/system.properties

And lastly, in this file, edit:

org.osgi.service.http.port=8182   #default is 8181
activemq.port = 61617   #default is 61616
activemq.jmx.url=service:jmx:rmi:///jndi/rmi://localhost:1098/karaf-${karaf.name}

Start up your brokers

Go and start up your brokers with $BASE/bin/amq script, and you should have two running brokers, without collisions on ports.