About Pascal Alma

Pascal is a senior JEE Developer and Architect at 4Synergy in The Netherlands. Pascal has been designing and building J2EE applications since 2001. He is particularly interested in Open Source toolstack (Mule, Spring Framework, JBoss) and technologies like Web Services, SOA and Cloud technologies. Specialties: JEE, SOA, Mule ESB, Maven, Cloud Technology, Amazon AWS.

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" />
</bean>

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

<transportConnectors>
  <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
  <transportConnector name="openwire" uri="tcp://0.0.0.0:61617?maximumConnections=1000&wireformat.maxFrameSize=104857600"/>
  <transportConnector name="amqp" uri="amqp://0.0.0.0:5673?maximumConnections=1000&wireformat.maxFrameSize=104857600"/>
 </transportConnectors>

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.
 

Related Whitepaper:

Functional Programming in Java: Harnessing the Power of Java 8 Lambda Expressions

Get ready to program in a whole new way!

Functional Programming in Java will help you quickly get on top of the new, essential Java 8 language features and the functional style that will change and improve your code. This short, targeted book will help you make the paradigm shift from the old imperative way to a less error-prone, more elegant, and concise coding style that’s also a breeze to parallelize. You’ll explore the syntax and semantics of lambda expressions, method and constructor references, and functional interfaces. You’ll design and write applications better using the new standards in Java 8 and the JDK.

Get it Now!  

Leave a Reply


four + = 5



Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.

Sign up for our Newsletter

20,709 insiders are already enjoying weekly updates and complimentary whitepapers! Join them now to gain exclusive access to the latest news in the Java world, as well as insights about Android, Scala, Groovy and other related technologies.

As an extra bonus, by joining you will get our brand new e-books, published by Java Code Geeks and their JCG partners for your reading pleasure! Enter your info and stay on top of things,

  • Fresh trends
  • Cases and examples
  • Research and insights
  • Two complimentary e-books