JMXApache ActiveMQ has extensive support for JMX to allow you to monitor and control the behavior of the broker via the JMX MBeans. Using JMX to monitor Apache ActiveMQYou can enable/disable JMX support as follows... 1. Run a broker setting the broker property useJmx to true (enabled by default) i.e. For xbean configuration <broker useJmx="true" brokerName="BROKER1"> ... </broker> 2. Run a JMX console $ jconsole 3. Connect to the given JMX URL: The ActiveMQ broker should appear in the list of local connections, if you are running JConsole on the same host as ActiveMQ. To connect to a remote ActiveMQ instance, or if the local process does not show up, use Remote Process option, and enter an URL. Here is an example localhost URL:
service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
Using the Apache ActiveMQ version on OS X it appears as follows:
ActiveMQ MBeans ReferenceFor additional references provided below is a brief hierarchy of the mbeans and a listing of the properties, attributes, and operations of each mbeans.
Command line utilities are also available to let you monitor ActiveMQ. Refer to ActiveMQ Command Line Tools Reference for usage information. JMX API is also exposed via REST management API Password Protecting the JMX Connector(For Java 1.5+) 1. Make sure JMX is enabled, but tell ActiveMQ not create its own connector so that it will use the default JVM JMX connector. <broker xmlns="http://activemq.org/config/1.0" brokerName="localhost"useJmx="true"> ... <managementContext> <managementContext createConnector="false"/> </managementContext> ... </broker> 2. Create access and password files conf/jmx.access: # The "monitorRole" role has readonly access. # The "controlRole" role has readwrite access. monitorRole readonly controlRole readwrite conf/jmx.password: # The "monitorRole" role has password "abc123". # The "controlRole" role has password "abcd1234". monitorRole abc123 controlRole abcd1234 (Make sure both files are not world readable - more info can be find here to protect files) For more details you can see the Monitoring Tomcat Document 3. Modify the "activemq" startup script (in bin) to enable the Java 1.5+ JMX connector Find the "SUNJMX=" line and change it too: 1. Windows SUNJMX=-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 SUNJMX="-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" This could be set in /etc/activemq.conf instead (if you have root access): 1. Windows ACTIVEMQ_HOME=DRIVE_LETTER:/where/ActiveMQ/is/installed ACTIVEMQ_BASE=%ACTIVEMQ_HOME% SUNJMX=-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} SUNJMX="-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" 4. Start ActiveMQ You should be able to connect to JMX on the JMX URL
service:jmx:rmi:///jndi/rmi://<your hostname>:1616/jmxrmi
And you will be forced to login. Advanced JMX ConfigurationThe activemq.xml configuration file allows you to configure how ActiveMQ is exposed to JMX for management. In some cases, you may need to tweak some of it's settings such as what port is used. Example:<broker useJmx="true"> <managementContext> <managementContext connectorPort="2011" jmxDomainName="test.domain"/> </managementContext> </broker> In 4.0.1 or later, on Java 1.5 or later we try and use the default platform MBeanServer (so that things like the JVM threads & memory settings are visible). If you wish to change the Java 5 JMX settings you can use various JMX system properties For example you can enable remote JMX connections to the Sun JMX connector, via setting the following environment variable (using set or export depending on your platform). These settings only configure the Sun JMX connector within Java 1.5+, not the JMX connector that ActiveMQ creates by default. SUNJMX=-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=1616 \ -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false (The SUNJMX environment variable is simple used by the "activemq" startup script, as additional startup parameters for java. If you start ActiveMQ directly, you'll have to pass these parameters yourself.) ManagementContext Properties Reference
|
