blob: ea70c9548853ea6e790c9c7a9f8f9de0fc1b888a [file] [log] [blame]
<div class="wiki-content maincontent"><h1>Introduction</h1><p>This article will provide more details on how to use ActiveMQ in <a shape="rect" href="http://karaf.apache.org/">Apache Karaf</a>, small OSGi based runtime. Apache Karaf was previously know as <em>ServiceMix kernel</em>, so informations found here are applicable to <a shape="rect" href="http://servicemix.apache.org/home.html">Apache ServiceMix Enterprise Service Bus</a> as well.</p><structured-macro ac:macro-id="2c896130-7d9d-44e3-90fe-6c0a154002c8" ac:name="note" ac:schema-version="1"><rich-text-body><p>Procedures described in this article were tested using Apache karaf 2.3.0</p></rich-text-body></structured-macro><h1>Installation</h1><p>ActiveMQ provides Karaf features which will help you integrate and use the broker in OSGi environment. For starters you need to add the features URL to Karaf. For version 5.9.0 you can do it like this:</p><structured-macro ac:macro-id="ce83faf0-9653-4d33-a754-abce466518f4" ac:name="code" ac:schema-version="1"><plain-text-body>karaf@root&gt; features:chooseurl activemq 5.9.0
</plain-text-body></structured-macro><p>After that you should see newly added features</p><structured-macro ac:macro-id="ecea4b99-311c-42a3-a2bb-38c7f41af388" ac:name="code" ac:schema-version="1"><plain-text-body>karaf@root&gt; features:list
State Version Name Repository
[uninstalled] [5.9.0 ] activemq-broker activemq-5.9.0
[uninstalled] [5.9.0 ] activemq-http activemq-5.9.0
[uninstalled] [5.9.0 ] activemq-camel activemq-5.9.0
[uninstalled] [5.9.0 ] activemq-web-console activemq-5.9.0
</plain-text-body></structured-macro><p>Installing and running the broker is as simple as installing <code>activemq-broker</code> feature, like</p><structured-macro ac:macro-id="826ce5f5-c195-4d48-929e-80b8562c7b6b" ac:name="code" ac:schema-version="1"><plain-text-body>karaf@root&gt; features:install activemq-broker
</plain-text-body></structured-macro><p>This will install and start the full broker (including the web console), just as if you started the standalone distribution.</p><h1>Broker Configuration</h1><p>Broker is configured using OSGi Config Admin mechanism and could be easily managed in <a shape="rect" href="http://karaf.apache.org/manual/latest-2.3.x/users-guide/configuration.html">Karaf</a>. Configuration can be done by modifying <code>${KARAF_BASE}/etc/org.apache.activemq.server-default.cfg</code> file or respective config admin property. An example of the file looks like</p><structured-macro ac:macro-id="e6d13142-ca34-4c78-b06d-64f022e58b88" ac:name="code" ac:schema-version="1"><plain-text-body>broker-name=amq-broker
data=${karaf.data}/${broker-name}
config=${karaf.base}/etc/activemq.xml</plain-text-body></structured-macro><p>Mandatory properties are listed in the following table</p><table><tbody><tr><th colspan="1" rowspan="1"><p>Property Name</p></th><th colspan="1" rowspan="1"><p>Property Description</p></th></tr><tr><td colspan="1" rowspan="1"><p>broker-name</p></td><td colspan="1" rowspan="1"><p>Name of the broker</p></td></tr><tr><td colspan="1" rowspan="1"><p>config</p></td><td colspan="1" rowspan="1"><p>Location of the XML configuration file</p></td></tr></tbody></table><p>You can also use this file to set other properties which will replace placeholders in XML configuration file, as the <code>${data</code>} property is used in this example.</p><p>Default XML configuration file is located in the <code>${KARAF_BASE}/etc/activemq.xml</code> by default.</p><h1>Web Console</h1><p>Web Console is installed by default and can be reached at <a shape="rect" class="external-link" href="http://localhost:8181/activemqweb/" rel="nofollow">http://localhost:8181/activemqweb/</a></p><p>The configuration for the console is done in a similar fashion to the broker itself. Configuration is located in <code>${KARAF_BASE}/etc/org.apache.activemq.webconsole.cfg</code> and by default looks like</p><structured-macro ac:macro-id="c0edaec0-8367-4b38-a720-6e2fc51bddde" ac:name="code" ac:schema-version="1"><plain-text-body>webconsole.jms.url=tcp://localhost:61616
webconsole.jmx.url=service:jmx:rmi:///jndi/rmi://localhost:1099/karaf-root
webconsole.jmx.user=karaf
webconsole.jmx.password=karaf</plain-text-body></structured-macro><p><strong>Optional:</strong> In order to use the ActiveMQ console with a broker configured with authentication, it is necessary to configure the username/password for JMS connection as well.</p><structured-macro ac:macro-id="8272db0f-f9c6-4843-91b8-7f405583b721" ac:name="code" ac:schema-version="1"><plain-text-body>webconsole.jms.user=system
webconsole.jms.password=manager
</plain-text-body></structured-macro><h1>Commands</h1><p>After these simple steps you have all necessary libraries installed in the container. Also, now you have specific commands on your disposal that you can use to manage your broker:</p><structured-macro ac:macro-id="5992cc54-3198-43b8-b64e-9ebeb1899ee5" ac:name="code" ac:schema-version="1"><plain-text-body> browse Display selected messages in a specified destination
bstat Displays useful broker statistics
list Lists all available brokers in the specified JMX context
purge Delete selected destination's messages that matches the message selector
query Display selected broker component's attributes and statistics
dstat Performs a predefined query that displays useful tabular statistics regarding the specified destination type&#160;</plain-text-body></structured-macro><structured-macro ac:macro-id="83559582-5e8d-453f-bf74-c03380d4111c" ac:name="tip" ac:schema-version="1"><parameter ac:name="title">Help on commands</parameter><rich-text-body><p>To obtain some detailed help on a given command, you can run:</p><structured-macro ac:macro-id="806e7673-bc97-4c75-970b-aa7ee2d22dd3" ac:name="code" ac:schema-version="1"><plain-text-body>activemq:[command] --help
</plain-text-body></structured-macro></rich-text-body></structured-macro><h2>Broker querying</h2><p>Several commands are available to query the broker. To address local brokers, you need to use the <code>--jmxlocal</code> parameter.</p><p>The following command displays available brokers:</p><structured-macro ac:macro-id="7c9b72b3-c17a-4cd4-8032-4bf278fbe3a0" ac:name="code" ac:schema-version="1"><plain-text-body>karaf@root&gt; activemq:list --jmxlocal
BrokerName = mybroker
</plain-text-body></structured-macro><p>To have more detailed informations, run:</p><structured-macro ac:macro-id="fb27593f-4cd4-4295-86c3-077b90f5bdd4" ac:name="code" ac:schema-version="1"><plain-text-body>karaf@root&gt; activemq:query --jmxlocal
</plain-text-body></structured-macro><p>It will display informations about the connectors, list of queues, etc...</p><p>You can also browse or purge queues using the <code>activemq:browse</code> and <code>activemq:purge</code> commands.</p></div>