ActiveMQ with separated lib-directory

Landing under rainbow (Airport Tempelhof), by Christoph Burmeister (own photo)

Landing under rainbow (Airport Berlin-Tempelhof), by Christoph Burmeister (own photo)

It’s easy to deploy an ActiveMQ-Broker. Just download it from the apache pages and extract all the files to a directory of your choice. If you need further libraries, for example to enable the embedded Camel-Routing-Engine with your own classes or their dependencies, just grab them via maven (or whatever) and push them to the lib-directory directly under %ActiveMQ_HOME%. The libraries will be automatically picked up by the Broker’s Main-Implementation. But what if your customer gives you other instructions where to put your configuration or libraries? It’s also easy but you have to know 😉

1st option: running without Tanuki’s wrapper:
With this solution you can easily use the java.ext.dirs-option in the activemq.bat-file. Simply add following:

set ACTIVEMQ_CLASSPATH = ...
set ACTIVEMQ_CUSTOM_LIBRARIES = %ACTIVEMQ_BASE%/otherlibs

and then add the java.ext.dirs-Option to the calling command:

"%_JAVACMD%" -Djava.ext.dirs="%ACTIVEMQ_CUSTOM_LIBRARIES%"  ...

That’s it. The libraries under %ACTIVEMQ_BASE%/otherlibs will be all found. If you’re using the option to extend the %ACTIVEMQ_CLASSPATH% you will have to define all the jar-names…

2nd option: running the broker wrapped by Tanuki’s wrapper

Simply add following lines to the wrapper.conf:

# Java Classpath (include wrapper.jar)  Add class path elements as
#  needed starting from 1
wrapper.java.classpath.1=%ACTIVEMQ_HOME%/bin/wrapper.jar
wrapper.java.classpath.2=%ACTIVEMQ_HOME%/bin/run.jar
wrapper.java.classpath.3=%MY_OWN_LIBRARY_LOCATION_1%/*
wrapper.java.classpath.4=%MY_OWN_LIBRARY_LOCATION_2%/*
wrapper.java.classpath.5=%MY_OWN_LIBRARY_LOCATION_3%/*
wrapper.java.classpath.6=%ACTIVEMQ_HOME%/lib/*
wrapper.java.classpath.7=%ACTIVEMQ_HOME%/lib/web/*
wrapper.java.classpath.8=%ACTIVEMQ_HOME%/lib/optional/*

It is all manged by the wrapper.conf, but you have to make sure, that the lib-directories of AMQ are also listed… Don’t know exactly why, but it works 🙂

Here’s the nabble for it: Nabble Thanks to Thorsten Mielke.