java 如何监控jms

1、	${ACTIVEMQ_HOME}/conf/activemq.xml 中的 broker 节点增加  useJmx="true" 属性
 
2、	${ACTIVEMQ_HOME}/conf/activemq.xml 中的 managementContext 节点修改成如下样子
 
	<managementContext>
	   <managementContext createConnector="true" connectorPort="11099" />
	</managementContext>	 
3.
vi 
/bin/activemq
ACTIVEMQ_SUNJMX_START="$ACTIVEMQ_SUNJMX_START -Dcom.sun.management.jmxremote -Djava.rmi.server.hostname=192.168.200.129"
然后用jconsole
service:jmx:rmi:///jndi/rmi://192.168.200.128:11099/jmxrmi

如果不写第三步,会出现如下错误

java.lang.RuntimeException: java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: 
	java.net.ConnectException: Connection refused: connect
	at org.apache.activemq.web.RemoteJMXBrokerFacade.createConnection(RemoteJMXBrokerFacade.java:165)
	at org.apache.activemq.web.RemoteJMXBrokerFacade.getMBeanServerConnection(RemoteJMXBrokerFacade.java:114)
	at org.apache.activemq.web.RemoteJMXBrokerFacade.getBrokerAdmin(RemoteJMXBrokerFacade.java:88)
	at com.example.monitor.ActivemqMonitor.ss(ActivemqMonitor.java:48)
	at com.example.monitor.ActivemqMonitor.main(ActivemqMonitor.java:26)
Caused by: java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is: 
	java.net.ConnectException: Connection refused: connect
	at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
	at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
	at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
	at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:110)
	at javax.management.remote.rmi.RMIServerImpl_Stub.newClient(Unknown Source)
	at javax.management.remote.rmi.RMIConnector.getConnection(RMIConnector.java:2327)
	at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:277)
	at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
	at org.apache.activemq.web.RemoteJMXBrokerFacade.createConnection(RemoteJMXBrokerFacade.java:146)
	... 4 more
Caused by: java.net.ConnectException: Connection refused: connect
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
	at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
	at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
	at java.net.Socket.connect(Socket.java:529)
	at java.net.Socket.connect(Socket.java:478)
	at java.net.Socket.<init>(Socket.java:375)
	at java.net.Socket.<init>(Socket.java:189)
	at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
	at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
	at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)

你可能感兴趣的:(java)