blob: d2520b19ba664546423c60257cb056ab68983940 [file] [log] [blame]
<div class="wiki-content maincontent"><h2 id="JMX-JMX">JMX</h2><p>Apache ActiveMQ has extensive support for JMX to allow you to monitor and control the behavior of the broker via the <a shape="rect" class="external-link" href="http://activemq.apache.org/maven/apidocs/org/apache/activemq/broker/jmx/package-summary.html">JMX MBeans</a>.</p><h3 id="JMX-UsingJMXtomonitorApacheActiveMQ">Using JMX to monitor Apache ActiveMQ</h3><p>You can enable/disable JMX support as follows...</p><p>1. <a shape="rect" href="run-broker.xml">Run a broker</a> setting the broker property useJmx to true (enabled by default) i.e.</p><p>For xbean configuration</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;broker useJmx=&quot;true&quot; brokerName=&quot;BROKER1&quot;&gt;
...
&lt;/broker&gt;
]]></script>
</div></div><p>2. Run a JMX console</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[$ jconsole ]]></script>
</div></div><p>3. The ActiveMQ broker should appear in the list of local connections, if you are running JConsole on the same host as ActiveMQ.</p><p><strong style="color: rgb(102,0,51);font-size: 16.0px;"><br clear="none"></strong></p><p><strong style="color: rgb(102,0,51);font-size: 16.0px;">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&#160;<a shape="rect" class="external-link" href="http://docs.oracle.com/javase/6/docs/technotes/guides/management/agent.html" rel="nofollow">Java Management guide</a>&#160;to configure the broker for remote management.</p><p>&#160;</p><p><span style="line-height: 1.4285715;">Using the Apache ActiveMQ version on OS X it appears as follows:</span></p><p><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image" src="jmx.data/activemq-jmx.png" data-image-src="/confluence/download/attachments/35976/activemq-jmx.png?version=1&amp;modificationDate=1181607318000&amp;api=v2" data-unresolved-comment-count="0" data-linked-resource-id="4495" data-linked-resource-version="1" data-linked-resource-type="attachment" data-linked-resource-default-alias="activemq-jmx.png" data-base-url="https://cwiki.apache.org/confluence" data-linked-resource-content-type="image/png" data-linked-resource-container-id="35976" data-linked-resource-container-version="39"></span><br clear="none"> &#160;</p><h3 id="JMX-ActiveMQMBeansReference">ActiveMQ 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><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>&#160;Mbean Type</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Properties / ObjectName&#160;</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Attributes&#160;</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Operations&#160;</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;Broker</p></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li><strong>type</strong>=Broker</li><li><strong>brokerName</strong>=&lt;broker identifier&gt;</li></ul></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>BrokerId</li><li>TotalEnqueueCount</li><li>TotalDequeueCount</li><li>TotalConsumerCount</li><li>TotalMessageCount</li><li>TotalConnectionsCount</li><li>TotalConsumerCount</li><li>TotalProducerCount</li><li>MemoryLimit</li><li>MemoryPercentUsage</li><li>StoreLimit</li><li>StorePercentUsage</li></ul></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>start</li><li>stop</li><li>terminateJVM</li><li>resetStatistics</li><li>gc</li></ul></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;Destination</p></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li><strong>type</strong>=Broker</li><li><strong>brokerName</strong>=&lt;name of broker&gt;</li><li><strong>destinationType</strong>=Queue|Topic</li><li><strong>destinationName</strong>=&lt;name&gt;</li></ul></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>AverageEnqueueTime</li><li><span style="line-height: 1.4285715;">ConsumerCount</span></li><li><span style="line-height: 1.4285715;">DequeueCount</span></li><li>EnqueueCount</li><li>ExpiredCount</li><li>InFlightCount</li><li><span style="line-height: 1.4285715;">MemoryLimit</span></li><li>MemoryPercentUsage</li><li>Name</li><li><span style="line-height: 1.4285715;">QueueSize (queues only)</span></li></ul></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>browseMessages</li><li>gc</li><li>purge</li><li>resetStatistics</li></ul></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;NetworkConnector</p></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li><strong>type</strong>=Broker</li><li><strong>brokerName</strong>=&lt;name of broker&gt;</li><li><strong>connector</strong>=networkConnectors</li><li><strong>networkConnectorName</strong>=&lt;connector identifier&gt;</li></ul></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>Name</li><li>Duplex</li><li>DynamicOnly</li><li>BridgeTempDestinations</li><li>ConduitSubscriptions</li><li>DecreaseNetworkConsumerPriority</li><li>DispatchAsync</li><li>DynamicOnly</li><li>NetworkTTL</li><li>Password</li><li>PrefetchSize</li></ul></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>start</li><li>stop</li></ul></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;Connector</p></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li><strong>type</strong>=Broker</li><li><strong>brokerName</strong>=&lt;name of broker&gt;</li><li><strong>connector</strong>=clientConnectors</li><li><strong>ConnectorName</strong>=&lt;connector identifier&gt;</li></ul></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>StatisticsEnabled</li></ul></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>start</li><li>stop</li><li>resetStatistics</li><li>enableStatistics</li><li>disableStatistics</li><li>connectionCount</li></ul></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;Connection</p></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li><strong>type</strong>=Broker</li><li><strong>brokerName</strong>=&lt;name of broker&gt;</li><li><strong>connectionViewType</strong>=clientId</li><li><strong>connectionName</strong>=&lt;connection identifier&gt;</li></ul></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>DispatchQueueSize</li><li>Active</li><li>Blocked</li><li>Connected</li><li>Slow</li><li>Consumers</li><li>Producers</li><li>RemoteAddress</li><li>UserName</li><li>ClientId</li></ul></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>start</li><li>stop</li><li>resetStatistics</li></ul></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160; PersistenceAdapter</p></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li><strong>type</strong>=Broker</li><li><strong>brokerName</strong>=&lt;broker name&gt;</li><li><strong>Service</strong>=PersistenceAdapter</li><li><strong>InstanceName</strong>=&lt;adapter identifier&gt;</li></ul></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>Name</li><li>Size</li><li>Data</li><li>Transactions</li></ul></td><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>&#160;Health</p></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li><strong>type</strong>=Broker</li><li><strong>brokerName</strong>=&lt;broker name&gt;</li><li><strong>Service</strong>=Health</li></ul></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>CurrentStatus</li></ul></td><td colspan="1" rowspan="1" class="confluenceTd"><ul><li>health</li></ul></td></tr></tbody></table></div><p>Command line utilities are also available to let you monitor ActiveMQ. Refer to <a shape="rect" href="activemq-command-line-tools-reference.xml">ActiveMQ Command Line Tools Reference</a> for usage information.</p><p>JMX API is also exposed via <a shape="rect" href="rest.xml#REST-RestManagement">REST management API </a></p><h3 id="JMX-PasswordProtectingtheJMXConnector">Password Protecting the JMX Connector</h3><p>(For Java 1.5+)</p><p>1. Make sure JMX is enabled, but tell ActiveMQ <strong>not</strong> create its own connector so that it will use the default JVM JMX connector.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;broker xmlns=&quot;http://activemq.org/config/1.0&quot; brokerName=&quot;localhost&quot;useJmx=&quot;true&quot;&gt;
...
&lt;managementContext&gt;
&lt;managementContext createConnector=&quot;false&quot;/&gt;
&lt;/managementContext&gt;
...
&lt;/broker&gt;
]]></script>
</div></div><p>2. Create access and password files</p><p>conf/jmx.access:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[# The &quot;monitorRole&quot; role has readonly access.
# The &quot;controlRole&quot; role has readwrite access.
monitorRole readonly
controlRole readwrite
]]></script>
</div></div><p>conf/jmx.password:</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[# The &quot;monitorRole&quot; role has password &quot;abc123&quot;.
# The &quot;controlRole&quot; role has password &quot;abcd1234&quot;.
monitorRole abc123
controlRole abcd1234
]]></script>
</div></div><p>(Make sure both files are not world readable - more info can be find <a shape="rect" class="external-link" href="http://java.sun.com/j2se/1.5.0/docs/guide/management/agent.html#auth" rel="nofollow">here</a> to protect files)</p><p>For more details you can see the <a shape="rect" class="external-link" href="http://tomcat.apache.org/tomcat-5.5-doc/monitoring.html">Monitoring Tomcat Document</a></p><p>3. 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 too the following: (note that in previous versions of ActiveMQ this property was called SUNJMX in some scripts. &#160;As of v5.12.0 all scripts use ACTIVEMQ_SUNJMX_START):</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[1. Windows
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
2. Unix
ACTIVEMQ_SUNJMX_START=&quot;-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&quot;
]]></script>
</div></div><p>This could be set in /etc/activemq.conf instead (if you have root access):</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[1. Windows
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
2. Unix
ACTIVEMQ_HOME=DRIVE_LETTER:/where/ActiveMQ/is/installed
ACTIVEMQ_BASE=${ACTIVEMQ_HOME}
ACTIVEMQ_SUNJMX_START=&quot;-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&quot;
]]></script>
</div></div><p>4. Start ActiveMQ</p><p>You should be able to connect to JMX on the JMX URL</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[service:jmx:rmi:///jndi/rmi://&lt;your hostname&gt;:1616/jmxrmi
]]></script>
</div></div><p>And you will be forced to login.</p><h3 id="JMX-SelectiveMBeanregistration">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="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="brush: xml; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[&lt;managementContext&gt;
&lt;managementContext 
suppressMBean=&quot;endpoint=dynamicProducer,endpoint=Consumer,connectionName=*,destinationName=ActiveMQ.Advisory.*&quot;
/&gt;
&lt;/managementContext&gt;]]></script>
</div></div><p>&#160;</p><h4 id="JMX-ManagementContextPropertiesReference">ManagementContext Properties Reference</h4><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Property Name</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Default Value</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>useMBeanServer</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>true</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If true then it avoids creating a new MBean server if a MBeanServer has already been created in the JVM</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>jmxDomainName</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>org.apache.activemq</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The jmx domain that all objects names will use</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>createMBeanServer</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>true</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If we should create the MBeanServer is none is found.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>createConnector</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>false</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><span style="color: rgb(119,119,119);"><span style="color: rgb(0,0,0);">Please refer to</span>&#160;</span><a shape="rect" class="external-link" href="http://docs.oracle.com/javase/6/docs/technotes/guides/management/agent.html" rel="nofollow">Java Management guide</a><span style="color: rgb(119,119,119);">&#160;<span style="color: rgb(0,0,0);">to configure the server for remote management and lock down the endpoint serialisation with an appropriate <a shape="rect" class="external-link" href="http://openjdk.java.net/jeps/290" rel="nofollow"> jdk.serialFilter</a></span></span></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>connectorPort</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>1099</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The port that the JMX connector will use</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>connectorHost</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>localhost</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The host that the JMX connector and RMI server (if rmiServerPort&gt;0) will use</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>rmiServerPort</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>0</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The RMI server port, handy if port usage needs to be restricted behind a firewall</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>connectorPath</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>/jmxrmi</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The path that JMX connector will be registered under</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>findTigerMBeanServer</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>true</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Enables/disables the searching for the Java 5 platform MBeanServer</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>suppressMBean</p></td><td colspan="1" rowspan="1" class="confluenceTd">&#160;</td><td colspan="1" rowspan="1" class="confluenceTd">List of MBean name patters to ignore</td></tr></tbody></table></div></div>