|
3 | 3 |
|
4 | 4 | [NOTE] |
5 | 5 | ==== |
6 | | -JMX support has been deprecated in 4.5 and will be removed in 5.0. + |
| 6 | +JMX support has been removed in 5.0. + |
7 | 7 | We recommend switching to Spring Boot https://docs.spring.io/spring-boot/reference/actuator/endpoints.html[Actuator Endpoints] and expose those over JMX if needed. |
8 | 8 | ==== |
9 | | - |
10 | | -The JMX support for MongoDB exposes the results of running the 'serverStatus' command on the admin database for a single MongoDB server instance. It also exposes an administrative MBean, `MongoAdmin`, that lets you perform administrative operations, such as dropping or creating a database. The JMX features build upon the JMX feature set available in the Spring Framework. See link:{springDocsUrl}/integration.html#jmx[here] for more details. |
11 | | - |
12 | | -[[mongodb:jmx-configuration]] |
13 | | -== MongoDB JMX Configuration |
14 | | - |
15 | | -Spring's Mongo namespace lets you enable JMX functionality, as the following example shows: |
16 | | - |
17 | | -.XML schema to configure MongoDB |
18 | | -==== |
19 | | -[source,xml] |
20 | | ----- |
21 | | -<?xml version="1.0" encoding="UTF-8"?> |
22 | | -<beans xmlns="http://www.springframework.org/schema/beans" |
23 | | - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
24 | | - xmlns:context="http://www.springframework.org/schema/context" |
25 | | - xmlns:mongo="http://www.springframework.org/schema/data/mongo" |
26 | | - xsi:schemaLocation=" |
27 | | - http://www.springframework.org/schema/context |
28 | | - https://www.springframework.org/schema/context/spring-context-3.0.xsd |
29 | | - http://www.springframework.org/schema/data/mongo |
30 | | - https://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd |
31 | | - http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> |
32 | | -
|
33 | | - <!-- Default bean name is 'mongo' --> |
34 | | - <mongo:mongo-client host="localhost" port="27017"/> |
35 | | -
|
36 | | - <!-- by default look for a Mongo object named 'mongo' --> |
37 | | - <mongo:jmx/> |
38 | | -
|
39 | | - <context:mbean-export/> |
40 | | -
|
41 | | - <!-- To translate any MongoExceptions thrown in @Repository annotated classes --> |
42 | | - <context:annotation-config/> |
43 | | -
|
44 | | - <bean id="registry" class="org.springframework.remoting.rmi.RmiRegistryFactoryBean" p:port="1099" /> |
45 | | -
|
46 | | - <!-- Expose JMX over RMI --> |
47 | | - <bean id="serverConnector" class="org.springframework.jmx.support.ConnectorServerFactoryBean" |
48 | | - depends-on="registry" |
49 | | - p:objectName="connector:name=rmi" |
50 | | - p:serviceUrl="service:jmx:rmi://localhost/jndi/rmi://localhost:1099/myconnector" /> |
51 | | -
|
52 | | -</beans> |
53 | | ----- |
54 | | -==== |
55 | | - |
56 | | -The preceding code exposes several MBeans: |
57 | | - |
58 | | -* `AssertMetrics` |
59 | | -* `BackgroundFlushingMetrics` |
60 | | -* `BtreeIndexCounters` |
61 | | -* `ConnectionMetrics` |
62 | | -* `GlobalLockMetrics` |
63 | | -* `MemoryMetrics` |
64 | | -* `OperationCounters` |
65 | | -* `ServerInfo` |
66 | | -* `MongoAdmin` |
67 | | - |
68 | | -The following screenshot from JConsole shows the resulting configuration: |
69 | | - |
70 | | -image::jconsole.png[] |
0 commit comments