blob: 941cd5e05a3fb116304ecd93bf498ac885990bb0 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>ActiveMQ</title>
<link rel="icon" type="image/png" href="/assets/img/favicon.png">
<link rel="stylesheet" href="/css/main.css">
<script defer src="https://use.fontawesome.com/releases/v5.0.8/js/all.js" integrity="sha384-SlE991lGASHoBfWbelyBPLsUlwY1GwNDJo3jSJO04KZ33K2bwfV9YBauFfnzvynJ" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light fixed-top">
<div class="container">
<!-- <a class="navbar-brand mr-auto" href="#"><img style="height: 50px" src="assets/img/apache-feather.png" /></a> -->
<a class="navbar-brand mr-auto" href="/"><img src="/assets/img/activemq_logo_black_small.png" style="height: 50px"/></a>
<button class="navbar-toggler ml-auto" type="button" data-toggle="collapse" data-target="#navbarContent" aria-controls="navbarContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="ml-auto collapse navbar-collapse" id="navbarContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link active" href="/index.html">Home</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link" id="navbarDropdownComponents" data-target="#" href="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Components</a>
<ul class="dropdown-menu dropdown-menu-center" aria-labelledby="navbarDropdownComponents">
<div class="row">
<div class="col-12">
<ul class="multi-column-dropdown">
<li class="nav-item"><a class="dropdown-item" href="/components/classic">ActiveMQ 5</a></li>
<li class="nav-item"><a class="dropdown-item" href="/components/artemis/">ActiveMQ Artemis</a></li>
<li class="nav-item"><a class="dropdown-item" href="/components/nms">NMS Clients</a></li>
<li class="nav-item"><a class="dropdown-item" href="/components/cms">CMS Client</a></li>
</ul>
</div>
</div>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link" id="navbarDropdownCommunity" data-target="#" href="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Contact</a>
<ul class="dropdown-menu dropdown-menu-center multi-column columns-1" aria-labelledby="navbarDropdownCommunity">
<div class="row">
<div class="col-12">
<ul class="multi-column-dropdown">
<li class="nav-item"><a class="dropdown-item" href="/contact#mailing">Mailing Lists</a></li>
<li class="nav-item"><a class="dropdown-item" href="/contact#chat">Chat</a></li>
<li class="nav-item"><a class="dropdown-item" href="/contact#issues">Report Issues</a></li>
<li class="nav-item"><a class="dropdown-item" href="/contact#contributing">Contributing</a></li>
<li class="nav-item"><a class="dropdown-item" href="/security-advisories.html">Security</a></li>
</ul>
</div>
</div>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link" id="navbarDropdownTeam" data-target="#" href="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Apache</a>
<ul class="dropdown-menu dropdown-menu-center multi-column columns-1" aria-labelledby="navbarDropdownTeam">
<div class="row">
<div class="col-sm-12">
<ul class="multi-column-dropdown">
<li class="nav-item"><a class="dropdown-item" href="https://www.apache.org">The Apache Software Foundation</a></li>
<li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/licenses/">License</a></li>
<li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li>
<li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/foundation/thanks.html">Thanks</a></li>
<li class="nav-item"><a class="dropdown-item" href="/security-advisories.html">Security</a></li>
<li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/events/current-event">Events</a></li>
<li class="nav-item"><a class="dropdown-item" href="https://people.apache.org/phonebook.html?pmc=activemq">PMC & Committers</a></li>
<li class="nav-item"><a class="dropdown-item" href="/team/reports">Board Reports</a></li>
</ul>
</div>
</div>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div class="content">
<div class="page-title-activemq5">
<div class="container">
<h1>OSGi Integration</h1>
</div>
</div>
<div class="container" >
<div class="row" style="margin-top: 30px">
<div class="col-12 activemq5">
<p><a href="connectivity">Connectivity</a> &gt; <a href="containers">Containers</a> &gt; <a href="osgi-integration">OSGi Integration</a></p>
<h1 id="introduction">Introduction</h1>
<p>This article will provide more details on how to use ActiveMQ in <a 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 href="http://servicemix.apache.org/home.html">Apache ServiceMix Enterprise Service Bus</a> as well.</p>
<blockquote>
<p>Procedures described in this article were tested using Apache karaf 2.3.0</p>
</blockquote>
<h1 id="installation">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>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>karaf@root&gt; features:chooseurl activemq 5.9.0
</code></pre></div></div>
<p>After that you should see newly added features</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>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
</code></pre></div></div>
<p>Installing and running the broker is as simple as installing <code class="highlighter-rouge">activemq-broker</code> feature, like</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>karaf@root&gt; features:install activemq-broker
</code></pre></div></div>
<p>This will install and start the full broker (including the web console), just as if you started the standalone distribution.</p>
<h1 id="broker-configuration">Broker Configuration</h1>
<p>Broker is configured using OSGi Config Admin mechanism and could be easily managed in <a href="http://karaf.apache.org/manual/latest-2.3.x/users-guideCommunity/FAQ/configuration">Karaf</a>. Configuration can be done by modifying <code class="highlighter-rouge">${KARAF_BASE}/etc/org.apache.activemq.server-default.cfg</code> file or respective config admin property. An example of the file looks like</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>broker-name=amq-broker
data=${karaf.data}/${broker-name}
config=${karaf.base}/etc/activemq.xml
</code></pre></div></div>
<p>Mandatory properties are listed in the following table</p>
<table>
<thead>
<tr>
<th>Property Name</th>
<th>Property Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>broker-name</td>
<td>Name of the broker</td>
</tr>
<tr>
<td>config</td>
<td>Location of the XML configuration file</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 class="highlighter-rouge">${data</code>} property is used in this example.</p>
<p>Default XML configuration file is located in the <code class="highlighter-rouge">${KARAF_BASE}/etc/activemq.xml</code> by default.</p>
<h1 id="web-console">Web Console</h1>
<p>Web Console is installed by default and can be reached at <a href="http://localhost:8181/activemqweb/">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 class="highlighter-rouge">${KARAF_BASE}/etc/org.apache.activemq.webconsole.cfg</code> and by default looks like</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>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
</code></pre></div></div>
<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>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>webconsole.jms.user=system
webconsole.jms.password=manager
</code></pre></div></div>
<h1 id="commands">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>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>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 
</code></pre></div></div>
<blockquote>
<p>Help on commands</p>
<p>To obtain some detailed help on a given command, you can run:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>activemq:[command] --help
</code></pre></div> </div>
</blockquote>
<h2 id="broker-querying">Broker querying</h2>
<p>Several commands are available to query the broker. To address local brokers, you need to use the <code class="highlighter-rouge">--jmxlocal</code> parameter.</p>
<p>The following command displays available brokers:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>karaf@root&gt; activemq:list --jmxlocal
BrokerName = mybroker
</code></pre></div></div>
<p>To have more detailed informations, run:</p>
<div class="highlighter-rouge"><div class="highlight"><pre class="highlight"><code>karaf@root&gt; activemq:query --jmxlocal
</code></pre></div></div>
<p>It will display informations about the connectors, list of queues, etc…</p>
<p>You can also browse or purge queues using the <code class="highlighter-rouge">activemq:browse</code> and <code class="highlighter-rouge">activemq:purge</code> commands.</p>
</div>
</div>
</div>
</div>
<div class="row sitemap">
<div class="col-sm-12">
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-3">
<div >
<img class="float-left" style="max-height: 100px" src="/assets/img/activemq_logo_white_vertical_small.png"/>
</div>
</div>
<div style="text-align: center; margin-bottom: 0px; margin-top: 30px; font-size: 65%" class="col-sm-6">
<p>Apache ActiveMQ, ActiveMQ, ActiveMQ Artemis, Apache, the Apache feather logo, and the Apache ActiveMQ project logo are trademarks of The Apache Software Foundation. Copyright &copy; 2019, The Apache Software Foundation. Licensed under <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a>.</p>
</div>
<div class="col-sm-3">
<div >
<a href="https://www.apache.org"><img class="float-right" style="margin-top: 10px; max-height: 80px" src="/assets/img/apache-logo-small.png"/></a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>