FAQ for JMX related issues in Open Message Queue Cannot resolve external resource into attachment.

If you are interested in contributing to this FAQ, please read the Contribution Guidelines.

Back to main Open MQ FAQ page
Back to Open MQ

Q: How do I connect to the broker using jconsole ?
A: jconsole is a JMX monitoring tool that is bundled with the JDK. You can connect to the broker using jconsole as a local process (ie a broker running on the same machine as jconsole) or as a remote process.
Local process
If you are using JDK 1.6 for the broker and jconsole, you can simply launch jconsole and the broker process will appear in the local process list. Select it and you will be monitoring the broker. No credentials are required here as long as you are running the broker and jconsole as the same user. Note that there is a bug in JDK 1.6 that causes the broker to exit when jconsole is used to connect to it as a local process: 6583000 - Attaching to local MQ broker process via jconsole causes broker JVM to seg fault. This bug is fixed in JDK 1.6u10.
If you are using JDK 1.5, the broker needs to be started up with additional command line options to allow for local process monitoring. This is done by starting up the broker using the '-vmargs' option to specify the 'com.sun.management.jmxremote' property to the Java VM as follows:

-vmargs -Dcom.sun.management.jmxremote

For example:

imqbrokerd -tty -name mybroker -vmargs -Dcom.sun.management.jmxremote

Once the above is done, the broker process will appear in jconsole's local process list.
Remote process
If the broker you want to monitor is running on another machine or if it is running JDK 1.5 and you cannot restart it with the '-vmargs' option as described above, then you will need to access it remotely. This means that you cannot rely on the broker process appearing on the local processes list in jconsole. What is needed here is the JMX URL to connect to. This can be done by running the 'imqcmd list jmx' command. Sample output:

% imqcmd list jmx
Listing JMX Connectors on the broker specified by:

-------------------------
Host         Primary Port
-------------------------
localhost    7676

Name      Active  URL
jmxrmi    true    service:jmx:rmi://yourhost/stub/rO0ABdmVyLlJlpIDJyGvQkwAAAARod97VdgAEAeA==

ssljmxrmi false

Successfully listed JMX Connectors.

The URL seen above (shortened for convenience) i.e.

service:jmx:rmi://yourhost/stub/rO0ABdmVyLlJlpIDJyGvQkwAAAARod97VdgAEAeA==

can be used to connect to the broker.
If 'imqcmd list jmx' does not list a URL e.g. it displays 'There are no JMX Connectors on the broker', check the broker log to check for any startup/initialization errors.
The MQ broker's JMX URL can be entered in the Advanced tab of the JDK 1.5 jconsole 'Connect to Agent' dialog:

or the Remote Process URL in the JDK 1.6 jconsole 'New Connection' dialog:

The User Name and Password here is whatever administrator credentials that are configured for the broker. The default administrator username and password are "admin" and "admin".
NOTE:
The JMX URL above is dynamic - this URL cannot be used for the broker if it is restarted. If the broker is restarted, 'imqcmd list jmx' needs to be run to determine the JMX URL once again. The URL above basically contains the serialized RMI JMX Connector stub that is used for making the JMX connection. If a JMX URL that is unchanging is needed, the broker can be started up with this additional option:

-startRmiRegistry

As the option suggests, an RMI registry will be launched as part of broker startup. The default RMI port used here is 1099. If this port is used on your machine, a different port can be specfied for this via:

-rmiRegistryPort

So, as an example, a broker can be started via:

imqbrokerd -startRmiRegistry -rmiRegistryPort 1098

A run of 'imqcmd list jmx will now show something like:

% imqcmd list jmx -u admin -pw admin
Listing JMX Connectors on the broker specified by:

-------------------------
Host         Primary Port
-------------------------
localhost    7676

Name      Active URL
jmxrmi    true   service:jmx:rmi://yourhost/jndi/rmi://yourhost:1098/yourhost/7676/jmxrmi
ssljmxrmi false

Successfully listed JMX Connectors.

The relevant URL is now:

service:jmx:rmi://yourhost/jndi/rmi://yourhost:1098/yourhost/7676/jmxrmi

which can be used across broker restarts. This URL no longer contains a serialized stub but points
to its location (in a RMI registry that is started by the broker).
One thing that is worth pointing out - the URL above is of the form:

service:jmx:rmi://yourhost/jndi/rmi://yourhost:1098/yourhost/7676/jmxrmi

Note that the host name 'yourhost' appears 3 times:

  1. The first occurrence of 'yourhost' specifies the host (and possibly port - see this FAQ entry: How do I start up an MQ broker so that jconsole can connect to it through a firewall ?) used for the RMI connection objects
  2. yourhost:1098 is the rmi registry host/port
  3. /yourhost/7676/jmxrmi is the location on the rmi registry where the RMI stub is stored

While the hostname in (1) and (2) above can be substituted with "localhost" (if it is the localhost), the hostname in (3) cannot be changed - the string that is seen here is a named location in the RMI registry that has nothing to do with the physical network host or IP.


Q: How do I view MBeans exposed as part of MQ's JMX API in jconsole ?
A: First you need to connect to the broker using jconsole. This is described in a separate FAQ entry: How do I connect to the broker using jconsole ?
Once jconsole is up and running and connected to the broker, select/view the MBeans tab. This tab will list the MBeans in the broker in a hierarchical list view, grouped according to domains. The MQ MBeans are in the domain

com.sun.messaging.jms.server

Expand this node. You will see a collection of other nodes. This list hierarchy is based on the ObjectName of the MQ MBeans. For example, the Object Name of the Destination Monitor MBean of the queue "SimpleQueue" is

com.sun.messaging.jms.server:type=Destination,subtype=Monitor,desttype=q,name="SimpleQueue"

The name above is of the form:

domain:key1=value1,key2=value2,...

The list nodes in jconsole are named after the values of the keys in the Object Name of the MBeans.

So to get to this MBean, the following nodes in the MBeans tab need to be expanded:

  • com.sun.messaging.jms.server
  • Destination
  • Monitor
  • q

and clicking or expanding the leaf node "SimpleQueue" will show you information on this MBean as shown below.


Q: How do I start up an MQ broker so that jconsole can connect to it through a firewall ?
A: It is useful to know the ports that are used in making a JMX connection especially if the broker is sitting behind a firewall. In this case, if a monitoring client (for example, jconsole) is outside the firewall and needs to connect to the broker:

  • the broker needs to be configured to specify the relevant ports for JMX traffic.
  • the firewall needs to allow traffic on these same ports.

The ports that are relevant for making a JMX connection to the broker are listed in the table below:

Port Default value Description
RMI Registry Port 1099 This is the port used by the RMI Registry. As described in the FAQ entry How do I connect to the broker using jconsole ? the broker can be started with the options -startRmiRegistry and -rmiRegistryPort. If this is done, the JMX connection process will involve traffic on this port. The client will first connect to the RMIRegistry to obtain the RMI Connector stub which it will then use to create the actual JMX connection.
Port used by RMI Connector None. This is dynamically allocated. This is the port that is actually used by the RMI Connector. This is set via the MQ broker property imq.jmx.connector.connector_name.port The default connector name is 'jmxrmi', so the property that would be used here is imq.jmx.connector.jmxrmi.port. This property can be set in the broker's config.properties file or specified on the command line when starting up the broker using the -D option. If this property is not specified, the port used will be allocated dynamically.

Example Usage
If the broker is using an RMI Registry, it can be started up via the following:

imqbrokerd -startRmiRegistry -rmiRegistryPort 1098 -Dimq.jmx.connector.jmxrmi.port=5656

The JMX URL that is seen in the output of 'imqcmd list jmx' will contain the port numbers specified. For example:

% imqcmd list jmx
Listing JMX Connectors on the broker specified by:

-------------------------
Host         Primary Port
-------------------------
localhost    7676

Name      Active URL
jmxrmi    true   service:jmx:rmi://yourhost:5656/jndi/rmi://yourhost:1098/yourhost/7676/jmxrmi
ssljmxrmi false

Successfully listed JMX Connectors.

After starting the broker as above, the firewall needs to allow traffic on ports 1098 and 5656 for JMX clients. Note that the firewall may need to also allow traffic on additional ports - for JMS traffic.
If the broker is not using an RMI Registry, the port used by the RMI Connector can still be specified with the imq.jmx.connector.jmxrmi.port property as follows:

imqbrokerd -Dimq.jmx.connector.jmxrmi.port=5656

In this case, the firewall needs to only allow traffic on port 5656 (in addition to other ports used by jms traffic).




jconsole1.5.gif (image/gif)
jconsole1.6.gif (image/gif)
simplequeue.gif (image/gif)
simplequeue.gif (image/gif)
jconsole1.6.gif (image/gif)
jconsole1.5.gif (image/gif)

Is there a possibility for a read only user to be able to connect to the jmx service? All I see is the ability for an admin to have access.

Posted by jgriff at Nov 02, 2010 11:44