This article applies to versions of ActiveMQ prior to 5.4.0. If you use version 5.4.0 or newer proceed to the following article.
All ActiveMQ modules are packaged as OSGi bundles and can be used in any OSGi container. This article will provide more details on how to use ActiveMQ in Apache Karaf, small OSGi based runtime. Apache Karaf was previously know as ServiceMix kernel, so informations found here are applicable to Apache ServiceMix Enterprise Service Bus as well.
ActiveMQ comes as a feature in ServiceMix (Karaf). So instead of installing all necessary bundles one by one, you can simply install it using a single command. But first of all, you need to setup ServiceMix features url.
Now you can install ActiveMQ like this
This command will install all necessary ActiveMQ bundles and if you type
you should see something like this
Once installed, this feature offers a special set of commands which enables you easily use the broker.
The following example shows how to create and destroy the broker using the create-broker and destroy-broker commands.
For more information on ActiveMQ feature take a look at the ServiceMix ActiveMQ integration guide
Web Console is included in ActiveMQ distribution and you'll probably want to have it to monitor your broker. First of all you'll have to install the web feature, so that you have a web container ready to deploy our web application. To do that you should first add the ServiceMix features url, like we did above (if you didn't already). Now, you can just run
to grab all necessary bundles. If you type
you'll see all installed bundles (such as)
The important thing is that we need to use proper versions of Pax web bundles to make all this work, and those are:
So if you have older bundles, like it is the case in our example, you'll need to unistall them and install new ones. To uninstall old bundles, simply look at their id and execute
In this example it would be
Now install new ones
After successful installation, you should start your newly added bundles. You can do that by executing
It's best to restart your container at this point and afterwards we're finally ready to deploy our war. To do that we'll use the Pax Web War Extender. The following example will use the latest 5.3-SNAPSHOT build and deploy it in the OSGi runtime
Also, if you have problems installing the war with the previous method, download it manually from https://repository.apache.org/content/repositories/snapshots/org/apache/activemq/activemq-web-console/5.3-SNAPSHOT/ and install using
Unfortunately the command
does not work with pax web war extender 0.5.1, but you try it if you're using the newer one.
If you execute
you'll see the newly added bundle here.
It's time t start it now
The important thing to note here is that by default, web console will start an embedded broker and monitor it. So if you have a broker already running it will fail to start.
Note that we have used activemqweb as a WebApp-Context while deploying the war, so the console will be available at http://localhost:8080/activemqweb. Visit this URL and administer your embedded broker.
There a big chance that you don't want to monitor an embedded broker, but the broker you have started separately (in the OSGi runtime or elsewhere). To configure your web console to do that, you have to do the following. First, exit your OSGi runtime. Now you can edit the etc/system.properties file and add some configuration details. The following configuration snippet
should work fine with default broker started in the Karaf (ServiceMix). Adapt it to your specific needs.
Now if you run the runtime (and the console bundle), you'll notice that the console will not start the broker and will try to use one defined with the system properties.
Visit http://localhost:8080/activemqweb and enjoy.