blob: 4bc46747a5271d18ed2661911b028e5f59057b2b [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="/js/fontawesome-all.min.js" integrity="sha384-rOA1PnstxnOBLzCLMcre8ybwbTmemjzdNlILg8O7z1lUkLXozs4DHonlDtnE7fpc"></script>
<script src="/js/jquery.slim.min.js" integrity="sha384-5AkRS45j4ukf+JbWAfHL8P4onPA9p0KwwP7pUdjSQA3ss9edbJUJc/XcYAiheSSz"></script>
<script src="/js/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"></script>
<script src="/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"></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="/news">News</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<span class="caret"></span></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 Classic</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">Community<span class="caret"></span></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">Contact Us</a></li>
<li class="nav-item"><a class="dropdown-item" href="/contributing">Contribute</a></li>
<li class="nav-item"><a class="dropdown-item" href="/issues">Report Issues</a></li>
<li class="nav-item"><a class="dropdown-item" href="/support">Get Support</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"><img src="/assets/img/feather.png" style="height:20px">Apache<span class="caret"></span></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">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="https://whimsy.apache.org/board/minutes/ActiveMQ.html">Board Reports</a></li>
<li class="nav-item"><a class="dropdown-item" href="https://privacy.apache.org/policies/privacy-policy-public.html">Privacy Policy</a></li>
</ul>
</div>
</div>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div class="content">
<div class="page-title-classic">
<div class="container">
<h1>JMX</h1>
</div>
</div>
<div class="container" >
<div class="row" style="margin-top: 30px">
<div class="col-12 classic">
<p><a href="features">Features</a> &gt; <a href="jmx">JMX</a></p>
<h2 id="jmx">JMX</h2>
<p>Apache ActiveMQ Classic has extensive support for JMX to allow you to monitor and control the behavior of the broker via the <a href="http://activemq.apache.org/maven/apidocs/org/apache/activemq/broker/jmx/package-summary.html">JMX MBeans</a>.</p>
<h3 id="using-jmx-to-monitor-apache-activemq-classic">Using JMX to monitor Apache ActiveMQ Classic</h3>
<p>You can enable/disable JMX support as follows…</p>
<ol>
<li>
<p><a href="run-broker">Run a broker</a> setting the broker property useJmx to true (enabled by default) i.e.</p>
<p>For xbean configuration</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> &lt;broker useJmx="true" brokerName="BROKER1"&gt;
...
&lt;/broker&gt;
</code></pre></div> </div>
</li>
<li>Run a JMX console
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>$ jconsole
</code></pre></div> </div>
</li>
<li>The ActiveMQ Classic broker should appear in the list of local connections, if you are running JConsole on the same host as ActiveMQ Classic.</li>
</ol>
<p><strong>JMX remote access</strong></p>
<p>Remote connections to JMX are not enabled by default in the activemq.xml for security reasons. Please refer to <a href="http://docs.oracle.com/javase/6/docs/technotes/guides/management/agent.html">Java Management guide</a> to configure the broker for remote management.</p>
<p>Using the Apache ActiveMQ Classic version on OS X it appears as follows:</p>
<p><img src="assets/img/activemq-jmx.png" alt="" /><br />
 </p>
<h3 id="activemq-classic-mbeans-reference">ActiveMQ Classic MBeans Reference</h3>
<p>For additional references provided below is a brief hierarchy of the mbeans and a listing of the properties, attributes, and operations of each mbeans.</p>
<table>
<thead>
<tr>
<th>Mbean Type</th>
<th>Properties / ObjectName </th>
<th>Attributes</th>
<th>Operations</th>
</tr>
</thead>
<tbody>
<tr>
<td>Broker</td>
<td><strong>type=Broker</strong>, <strong>brokerName=&lt;broker-identifier&gt;</strong></td>
<td>BrokerId, TotalEnqueueCount, TotalDequeueCount, TotalConsumerCount, TotalMessageCount, TotalConnectionsCount, TotalConsumerCount, TotalProducerCount, MemoryLimit, MemoryPercentUsage, StoreLimit, StorePercentUsage</td>
<td>start, stop, terminateJVM, resetStatistics, gc</td>
</tr>
<tr>
<td>Destination</td>
<td><strong>type=Broker</strong>, <strong>brokerName=&lt;name-of-broker&gt;</strong>, <strong>destinationType=Queue|Topic</strong>, <strong>destinationName=&lt;name&gt;</strong></td>
<td>Average, EnqueueTime, ConsumerCount, DequeueCount, EnqueueCount, ExpiredCount, InFlightCount, MemoryLimit, MemoryPercentUsage, Name, QueueSize (queues only)</td>
<td>browseMessages, gc, purge, resetStatistics</td>
</tr>
<tr>
<td>NetworkConnector</td>
<td><strong>type=Broker</strong>, <strong>brokerName==&lt;name-of-broker&gt;</strong>, <strong>connector=networkConnectors</strong>, <strong>networkConnectorName==&lt;connector-identifier&gt;</strong></td>
<td>Name, Duplex, DynamicOnly, BridgeTempDestinations, ConduitSubscriptions, DecreaseNetworkConsumerPriority, DispatchAsync, DynamicOnly, NetworkTTL, Password, PrefetchSize</td>
<td>start, stop</td>
</tr>
<tr>
<td>Connector</td>
<td><strong>type=Broker</strong>, <strong>brokerName=&lt;name-of-broker&gt;</strong>, <strong>connector=clientConnectors</strong>, <strong>ConnectorName==&lt;connector-identifier&gt;</strong></td>
<td>StatisticsEnabled</td>
<td>start, stop, resetStatistics, enableStatistics, disableStatistics, connectionCount</td>
</tr>
<tr>
<td>Connection</td>
<td><strong>type=Broker</strong>, <strong>brokerName=&lt;name-of-broker&gt;</strong>, <strong>connectionViewType=clientId</strong>, <strong>connectionName==&lt;connection-identifier&gt;</strong></td>
<td>DispatchQueueSize, Active, Blocked, Connected, Slow, Consumers, Producers, RemoteAddress, UserName, ClientId</td>
<td>start, stop, resetStatistics</td>
</tr>
<tr>
<td>PersistenceAdapter</td>
<td><strong>type=Broker</strong>, <strong>brokerName=&lt;name-of-broker&gt;</strong>, <strong>Service=PersistenceAdapter</strong>, <strong>InstanceName==&lt;adapter-identifier&gt;</strong></td>
<td>Name, Size, Data, Transactions</td>
<td> </td>
</tr>
<tr>
<td>Health</td>
<td><strong>type=Broker</strong>, <strong>brokerName=&lt;name-of-broker&gt;</strong>, <strong>Service=Health</strong></td>
<td>CurrentStatus</td>
<td>health</td>
</tr>
</tbody>
</table>
<p>Command line utilities are also available to let you monitor ActiveMQ Classic. Refer to <a href="activemq-classic-command-line-tools-reference">ActiveMQ Classic Command Line Tools Reference</a> for usage information.</p>
<p>JMX API is also exposed via <a href="rest">REST management API</a></p>
<h3 id="password-protecting-the-jmx-connector">Password Protecting the JMX Connector</h3>
<p>(For Java 1.5+)</p>
<ol>
<li>Make sure JMX is enabled, but tell ActiveMQ Classic <strong>not</strong> create its own connector so that it will use the default JVM JMX connector.
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> &lt;broker xmlns="http://activemq.org/config/1.0" brokerName="localhost"useJmx="true"&gt;
...
&lt;managementContext&gt;
&lt;managementContext createConnector="false"/&gt;
&lt;/managementContext&gt;
...
&lt;/broker&gt;
</code></pre></div> </div>
</li>
<li>
<p>Create access and password files</p>
<p>conf/jmx.access:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> # The "monitorRole" role has readonly access.
# The "controlRole" role has readwrite access.
monitorRole readonly
controlRole readwrite
</code></pre></div> </div>
<p>conf/jmx.password:</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> # The "monitorRole" role has password "abc123".
# The "controlRole" role has password "abcd1234".
monitorRole abc123
controlRole abcd1234
</code></pre></div> </div>
<p>(Make sure both files are not world readable - more info can be find <a href="http://java.sun.com/j2se/1.5.0/docs/guide/management/agent.html#auth">here</a> to protect files)</p>
<p>For more details you can see the <a href="http://tomcat.apache.org/tomcat-5.5-doc/monitoring.html">Monitoring Tomcat Document</a></p>
</li>
<li>
<p>Modify the “activemq” startup script (in bin) to enable the Java 1.5+ JMX connector</p>
<p>Find the “ACTIVEMQ_SUNJMX_START=” line and change it to the following: (note that in previous versions of ActiveMQ Classic this property was called SUNJMX in some scripts.  As of v5.12.0 all scripts use ACTIVEMQ_SUNJMX_START):</p>
<ol>
<li>Windows
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> ACTIVEMQ_SUNJMX_START=-Dcom.sun.management.jmxremote.port=1616 -Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.password.file=%ACTIVEMQ_BASE%/conf/jmx.password \
-Dcom.sun.management.jmxremote.access.file=%ACTIVEMQ_BASE%/conf/jmx.access
</code></pre></div> </div>
</li>
<li>Unix
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> ACTIVEMQ_SUNJMX_START="-Dcom.sun.management.jmxremote.port=1616 -Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.password.file=${ACTIVEMQ_BASE}/conf/jmx.password \
-Dcom.sun.management.jmxremote.access.file=${ACTIVEMQ_BASE}/conf/jmx.access"
</code></pre></div> </div>
</li>
</ol>
<p>This could be set in /etc/activemq.conf instead (if you have root access):</p>
<ol>
<li>Windows
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> ACTIVEMQ_HOME=DRIVE_LETTER:/where/ActiveMQ/is/installed
ACTIVEMQ_BASE=%ACTIVEMQ_HOME%
ACTIVEMQ_SUNJMX_START=-Dcom.sun.management.jmxremote.port=1616 -Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.password.file=%ACTIVEMQ_BASE%/conf/jmx.password \
-Dcom.sun.management.jmxremote.access.file=%ACTIVEMQ_BASE%/conf/jmx.access
</code></pre></div> </div>
</li>
<li>Unix
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> ACTIVEMQ_HOME=DRIVE_LETTER:/where/ActiveMQ/is/installed
ACTIVEMQ_BASE=${ACTIVEMQ_HOME}
ACTIVEMQ_SUNJMX_START="-Dcom.sun.management.jmxremote.port=1616 -Dcom.sun.management.jmxremote.ssl=false \
-Dcom.sun.management.jmxremote.password.file=${ACTIVEMQ_BASE}/conf/jmx.password \
-Dcom.sun.management.jmxremote.access.file=${ACTIVEMQ_BASE}/conf/jmx.access"
</code></pre></div> </div>
</li>
</ol>
</li>
<li>Start ActiveMQ Classic</li>
</ol>
<p>You should be able to connect to JMX on the JMX URL</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>service:jmx:rmi:///jndi/rmi://&lt;your hostname&gt;:1616/jmxrmi
</code></pre></div></div>
<p>And you will be forced to login.</p>
<h3 id="selective-mbean-registration">Selective MBean registration</h3>
<p>In situations where you need to scale your broker to large number of connections, destinations and consumers it can become very expensive to keep JMX MBeans for all those objects. Instead of turning off JMX completely, starting with 5.12.0, you can selectively suppress registration of some types of MBeans and thus help your broker scale, while still having a basic view of the broker state.</p>
<p>For example, the following configuration will exclude all dynamic producers, consumers, connections and advisory topics from registering their MBeans</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>&lt;managementContext&gt;
&lt;managementContext suppressMBean="endpoint=dynamicProducer,endpoint=Consumer,connectionName=*,destinationName=ActiveMQ.Advisory.*"/&gt;
&lt;/managementContext&gt;
</code></pre></div></div>
<h4 id="managementcontext-properties-reference">ManagementContext Properties Reference</h4>
<table>
<tbody>
<tr>
<td>Property Name</td>
<td>Default Value</td>
<td>Description</td>
</tr>
<tr>
<td>useMBeanServer</td>
<td>true</td>
<td>If true then it avoids creating a new MBean server if a MBeanServer has already been created in the JVM</td>
</tr>
<tr>
<td>jmxDomainName</td>
<td>org.apache.activemq</td>
<td>The jmx domain that all objects names will use</td>
</tr>
<tr>
<td>createMBeanServer</td>
<td>true</td>
<td>If we should create the MBeanServer is none is found.</td>
</tr>
<tr>
<td>createConnector</td>
<td>false</td>
<td>Please refer to <a href="http://docs.oracle.com/javase/6/docs/technotes/guides/management/agent.html">Java Management guide</a> to configure the server for remote management and lock down the endpoint serialisation with an appropriate <a href="http://openjdk.java.net/jeps/290">jdk.serialFilter</a><br /><br />Note: if set to true:<br />* lock down the endpoint serialisation with an appropriate jdk.serialFilter<br />* configure rmiServerPort and connectorHost to lock down the RMI server interface binding</td>
</tr>
<tr>
<td>connectorPort</td>
<td>1099</td>
<td>The port that the JMX connector will use</td>
</tr>
<tr>
<td>connectorHost</td>
<td>localhost</td>
<td>The host that the JMX connector and RMI server (if rmiServerPort&gt;0) will use</td>
</tr>
<tr>
<td>rmiServerPort</td>
<td>0</td>
<td>The RMI server port, handy if port usage needs to be restricted behind a firewall</td>
</tr>
<tr>
<td>connectorPath</td>
<td>/jmxrmi</td>
<td>The path that JMX connector will be registered under</td>
</tr>
<tr>
<td>findTigerMBeanServer</td>
<td>true</td>
<td>Enables/disables the searching for the Java 5 platform MBeanServer</td>
</tr>
<tr>
<td>suppressMBean</td>
<td> </td>
<td>List of MBean name patters to ignore</td>
</tr>
</tbody>
</table>
</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><a href="https://www.apache.org/foundation/marks/list/">Apache, ActiveMQ, Apache ActiveMQ</a>, the Apache feather logo, and the Apache ActiveMQ project logo are trademarks of The Apache Software Foundation. Copyright &copy; 2024, 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>