summaryrefslogtreecommitdiff
path: root/qpid/doc/book/src/java-broker/Java-Broker-Configuring-And-Managing-JMX.xml
blob: 026213c157b1eb5c129fb6858e2d6b8b8eabf1f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE entities [
<!ENTITY %  entities SYSTEM  "commonEntities.xml">
%entities;
]>
<!--

 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.

-->

<section id="Java-Broker-Configuring-And-Managing-JMX-Management">
    <title>JMX Management</title>

    <section id="Java-Broker-Configuring-And-Managing-JMX-Management-Introduction">
        <title>Introduction</title>
        <para>The JMX management plugin provides a series of managed beans (MBeans) allowing you to
            control and monitor the Broker via an industry compliant interface. This provides a
            convenient intergration point for a variety of Infrastructure Monitoring Solutions,
            tools such as Jconsole and VisualVM, as well as custom Java programs and scripts.</para>
        <para>The following sections describe how to connect to JMX, the configuration of the JMX
            plugin covering topis including securing with SSL, programmatically interacting with
            Qpid MBeans and finally a summary of all the MBeans made available from by the
            plugin.</para>
        <important>
            <para>For new development work, the reader is directed towards the strategic <link
                    linkend="Java-Broker-Configuring-And-Managing-Web-Console">Web Management
                    Console</link> and the <link
                    linkend="Java-Broker-Configuring-And-Managing-REST-API">REST API</link>. Use the
                Web/REST interfaces in preference to JMX whenever possible. The JMX interface may be
                withdrawn in a future release.</para>
        </important>
    </section>

    <section id="Java-Broker-Configuring-And-Managing-JMX-Management-Plugin-DefaultConfiguration">
        <title>Default Configuration</title>
        <para>By default, the Broker is shipped with JMX enabled.</para>
        <para>The RMI registry port runs on port <literal>8999</literal> and the JMX connector on
            port <literal>9099</literal>. The connector is not SSL protected. Qpid will use the
                <ulink
                url="&oracleJdkDocUrl;java/lang/management/ManagementFactory.html#getPlatformMBeanServer()"
                >Platform MBeanServer</ulink>.</para>
        <para>To change these settings, use the <link
                linkend="Java-Broker-Configuring-And-Managing-Web-Console">Web Management
                interface</link>.</para>
    </section>

    <section id="Java-Broker-Configuring-And-Managing-JMX-Management-Plugin-ConnectingToJMX">
        <title>Connecting to JMX</title>
        <para>The following example uses Jconsole to illustrates how to connect to JMX and assume
            the defaults described above. Jconsole is a management tool that comes with the JDK. It
            provides a very simple view of the MBeans, but requires no special configuration to be
            used with Qpid.</para>
        <para>For full details of Jconsole itself refer to Oracle's <ulink url="&oracleJconsole;"
                >JConsole Guide</ulink>.</para>
        <para>Jconsole can be used to connect to local or remote Java processes. On startup, it
            presents a list of all the Java processes running on the local host and also allows you
            to specify a service url to connect to a Java process running on a remote host.</para>
        <para>To start Jconsole on the command line, type:</para>
        <programlisting><![CDATA[jconsole]]></programlisting>
        <section
            id="Java-Broker-Configuring-And-Managing-JMX-Management-Plugin-ConnectingToJMX-Local">
            <title>Local</title>
            <para>To connect to a Broker running locally, simply select the process from the list.
                You can identify the Broker by looking for its classname
                    <literal>org.apache.qpid.server.Main</literal>.</para>
        </section>
        <section
            id="Java-Broker-Configuring-And-Managing-JMX-Management-Plugin-ConnectingToJMX-Remote">
            <title>Remote</title>
            <para>To connect to a broker running remotely, provide the hostname and port number of
                the <emphasis>RMI registry port</emphasis> (e.g. <literal>hostname:8999</literal>)
                and a valid username and password.</para>
            <para>You can also provide a service url in the form
                    <literal>service:jmx:rmi:///jndi/rmi://hostname:8999/jmxrmi</literal></para>
            <figure>
                <title>Making a remote JMX connection to a Broker using jconsole</title>
                <graphic fileref="images/JMX-Connect-Remote.png"/>
            </figure>
        </section>
        <para>Once you are connected expand the tree of nodes marked
                <literal>org.apache.qpid</literal> to begin to interact with the Qpid MBeans.</para>
        <figure>
            <title>Qpid MBean hierarchy</title>
            <graphic fileref="images/JMX-Connect-MBeans.png"/>
        </figure>
        <section id="Java-Broker-Configuring-And-Managing-JMX-Management-Plugin-ConnectingToJMX-SSL">
            <title>Connecting to a remote Broker protected by SSL</title>
            <para>If you are connecting to a remote Broker whose JMX connector port has been secured
                with SSL certificate signed by a private CA (or a self-signed certificate), you will
                need to pass a trust store and trust store password to Jconsole. If this is
                required, start jconsole with the following options:</para>
            <programlisting><![CDATA[jconsole -J-Djavax.net.ssl.trustStore=jmxtruststore.jks -J-Djavax.net.ssl.trustStorePassword=password]]></programlisting>
        </section>
    </section>

    <section id="Java-Broker-Configuring-And-Managing-JMX-Example-Client">
        <title>Example JMX Client</title>
        <para>The following java snippet illustrates a JMX client that connects to Qpid over JMX
            passing a userid and password, looks up the <ulink
                url="&qpidManagementCommonSrc;org/apache/qpid/management/common/mbeans/ManagedBroker&qpidSrcSuffix;"
                >ManagedBroker</ulink> object corresponding to the <literal>myvhost</literal>
            virtualhost, then invokes a method on the virtualhost to create a new queue.</para>
        <para>A full introduction to custom JMX clients is beyond the scope of this book. For this
            the reader is directed toward Oracle's <ulink url="&oracleJmxTutorial;">JMX
                tutorial.</ulink></para>
        <example id="Java-Broker-Configuring-And-Managing-JMX-Example-Client-Code">
            <title>JMX Client illustrating the creation of a new queue</title>
            <programlisting language="java">
Map&lt;String, Object&lt; environment = new HashMap&lt;String, Object&gt;();
environment.put(JMXConnector.CREDENTIALS, new String[] {"admin","password"});
// Connect to service
JMXServiceURL url =  new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:8999/jmxrmi");
JMXConnector jmxConnector = JMXConnectorFactory.connect(url, environment);
MBeanServerConnection mbsc =  jmxConnector.getMBeanServerConnection();
// Object name for ManagedBroker mbean for virtualhost myvhost
ObjectName objectName = new ObjectName("org.apache.qpid:type=VirtualHost.VirtualHostManager,VirtualHost=\"myvhost\"");
// Get the ManagedBroker object
ManagedBroker managedBroker = JMX.newMBeanProxy(mbsc, objectName, ManagedBroker.class);;

// Create the queue named "myqueue"
managedBroker.createNewQueue("myqueue", null, true);</programlisting>
        </example>
        <para>The Qpid classes required for a custom JMX client are included in the
                <literal>qpid-management-common</literal> artefact.</para>
    </section>

    <section id="Java-Broker-Configuring-And-Managing-JMX-Management-MBeans">
        <title>The MBeans</title>
        <para>The following table summarises the available MBeans. The MBeans are self-describing:
            each attribute and operation carry a description describing their purpose. This
            description is visible when using tools such Jconsole. They are also available on
            Management interfaces themselves (linked below).</para>
        <table>
            <title>Qpid Broker MBeans</title>
            <tgroup cols="2">
                <thead>
                    <row>
                        <entry>Management Interface</entry>
                        <entry>Object Name</entry>
                    </row>
                </thead>
                <tbody>
                    <row>
                        <entry morerows="1">
                            <para>
                                <ulink
                                    url="&qpidManagementCommonSrc;org/apache/qpid/management/common/mbeans/ManagedBroker&qpidSrcSuffix;"
                                    >ManagedBroker</ulink>
                            </para>
                        </entry>
                        <entry>
                            <para>
                                <literal>org.apache.qpid:type=VirtualHost.VirtualHostManager,VirtualHost="<replaceable>virtualhostname</replaceable>"</literal>
                            </para>
                        </entry>
                    </row>
                    <row>
                        <entry>
                            <para>MBean corresponding to the named virtualhost. Allows operations
                                such as the creation/deletion of queues and exchanges on that
                                virtualhost and virtualhost levell statistics.</para>
                        </entry>
                    </row>
                    <row>
                        <entry morerows="1">
                            <para>
                                <ulink
                                    url="&qpidManagementCommonSrc;org/apache/qpid/management/common/mbeans/ManagedQueue&qpidSrcSuffix;"
                                    >ManagedQueue</ulink>
                            </para>
                        </entry>
                        <entry>
                            <para>
                                <literal>org.apache.qpid:type=VirtualHost.Queue,VirtualHost="<replaceable>virtualhostname</replaceable>",name="<replaceable>queuename</replaceable>"</literal>
                            </para>
                        </entry>
                    </row>
                    <row>
                        <entry>
                            <para>MBean corresponding to the named queue on the given virtualhost.
                                Allows queue management operations such as view message, move
                                message and clear queue. Exposes attributes such as queue depth and
                                durability.</para>
                        </entry>
                    </row>
                    <row>
                        <entry morerows="1">
                            <para>
                                <ulink
                                    url="&qpidManagementCommonSrc;org/apache/qpid/management/common/mbeans/ManagedExchange&qpidSrcSuffix;"
                                    >ManagedExchange</ulink>
                            </para>
                        </entry>
                        <entry>
                            <para>
                                <literal>org.apache.qpid:type=VirtualHost.Exchange,VirtualHost="<replaceable>virtualhostname</replaceable>",name="<replaceable>amq.direct</replaceable>",ExchangeType=<replaceable>type</replaceable></literal>
                            </para>
                        </entry>
                    </row>
                    <row>
                        <entry>
                            <para>MBean corresponding to the named exchange on the given
                                virtualhost. Allows exchange management operations such as the
                                creation and removal of bindings. The supported exchange types are
                                exposed by the <literal>exchangeTypes</literal> attribute of the
                                virtualhost.</para>
                        </entry>
                    </row>
                    <row>
                        <entry morerows="1">
                            <para>
                                <ulink
                                    url="&qpidManagementCommonSrc;org/apache/qpid/management/common/mbeans/ManagedConnection&qpidSrcSuffix;"
                                    >ManagedConnection</ulink>
                            </para>
                        </entry>
                        <entry>
                            <para>
                                <literal>org.apache.qpid:type=VirtualHost.Connection,VirtualHost="<replaceable>virtualhostname</replaceable>",name="<replaceable>/peerid:ephemeralport</replaceable>"</literal>
                            </para>
                        </entry>
                    </row>
                    <row>
                        <entry>
                            <para>MBean representing a active AMQP connection to the named virtual
                                host. Name is formed from the IP and ephemeral port of the peer.
                                Attributes include the client version and connection level
                                statistics.</para>
                        </entry>
                    </row>
                    <row>
                        <entry morerows="1">
                            <para>
                                <ulink
                                    url="&qpidManagementCommonSrc;org/apache/qpid/management/common/mbeans/UserManagement&qpidSrcSuffix;"
                                    >UserManagement</ulink>
                            </para>
                        </entry>
                        <entry>
                            <para>
                                <literal>org.apache.qpid:type=UserManagement,name="UserManagement-<replaceable>authentication
                                        manager name</replaceable>"</literal>
                            </para>
                        </entry>
                    </row>
                    <row>
                        <entry>
                            <para>When using <link
                                    linkend="Java-Broker-Security-PlainPasswordFile-Provider">Plain
                                    password provider</link> or <link
                                    linkend="Java-Broker-Security-Base64MD5PasswordFile-Provider"
                                    >Base 64 MD5 password provider</link>, permits user operations
                                such creation and deletion of users. and password changes.</para>
                        </entry>

                    </row>
                    <row>
                        <entry morerows="1">
                            <para>
                                <ulink
                                    url="&qpidManagementCommonSrc;org/apache/qpid/management/common/mbeans/ServerInformation&qpidSrcSuffix;"
                                    >ServerInformation</ulink>
                            </para>
                        </entry>
                        <entry>
                            <para>
                                <literal>org.apache.qpid:type=ServerInformation,name=ServerInformation</literal>
                            </para>
                        </entry>
                    </row>
                    <row>
                        <entry>
                            <para>Exposes broker wide statistics, product version number and JMX
                                management API version number.</para>
                        </entry>

                    </row>
                    <row>
                        <entry morerows="1">
                            <para>
                                <ulink
                                    url="&qpidManagementCommonSrc;org/apache/qpid/management/common/mbeans/LoggingManagement&qpidSrcSuffix;"
                                    >LoggingManagement</ulink>
                            </para>
                        </entry>
                        <entry>
                            <para>
                                <literal>org.apache.qpid:type=LoggingManagement,name=LoggingManagement</literal>
                            </para>
                        </entry>
                    </row>
                    <row>
                        <entry>
                            <para>MBean permitting control of the Broker's logging. Exposes
                                operations allow the logging level to be controlled at runtime
                                (without restarting the Broker) and others that allow changes to be
                                written back to the log4j.xml logging configuration file, or the
                                contents of the log4.xml file to be re-read at runtime.</para>
                        </entry>
                    </row>
                </tbody>
            </tgroup>
        </table>
    </section>
</section>