Activemq Jolokia
打开JMX
<broker … useJmx="true">
…
<managementContext>
<managementContext createConnector="true"/>
</managementContext>
</broker>
启动ActiveMQ
$ activemq start
启动 JMX console
$ jconsole
选择远程进程,输入url:
service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
访问ActiveMQ Jolokia REST API
read | Reading of MBean attributes |
write | Setting of MBean attributes |
exec | Execution of JMX operations |
list | List the available MBeans along with their supported attributes and operations. |
search | Searching for MBeans |
version | Getting version and server information |
每种命令的url格式。
<base-url>/read/<mbean name>/<attribute name>/<inner path>
<base url>/write/<mbean name>/<attribute name>/<value>/<inner path>
<base url>/exec/<mbean name>/<operation name>/<arg1>/<arg2>/....
<base-url>/search/<pattern>
<base-url>/list/<inner path>
<base-url>/version
例子:
拿到broker的属性值
http://localhost:8161/api/jolokia/read/org.apache.activemq:brokerName=localhost,type=Broker
{
"timestamp": 1463105087,
"status": 200,
"request": {
"mbean": "org.apache.activemq:brokerName=localhost,type=Broker",
"type": "read"
},
"value": {
"BrokerId": "ID:NOTE140082-51092-1463022383093-0:1",
"TemporaryQueues": [],
"StompSslURL": "",
"TemporaryTopicProducers": [],
"StoreLimit": 107374182400,
"TotalConsumerCount": 0,
"DurableTopicSubscribers": [],
"Slave": false,
"StompURL": "stomp:\/\/NOTE140082:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600",
"TopicSubscribers": [],
"QueueProducers": [],
"VMURL": "vm:\/\/localhost",
"Uptime": "22 hours 58 minutes",
"TotalMessageCount": 0,
"Topics": [
{
"objectName": "org.apache.activemq:brokerName=localhost,destinationName=ActiveMQ.Advisory.MasterBroker,destinationType=Topic,type=Broker"
},
{
"objectName": "org.apache.activemq:brokerName=localhost,destinationName=ActiveMQ.Advisory.Queue,destinationType=Topic,type=Broker"
}
],
"TopicProducers": [],
"BrokerName": "localhost",
"OpenWireURL": "tcp:\/\/NOTE140082:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600",
"MinMessageSize": 1024,
"QueueSubscribers": [],
"TotalDequeueCount": 0,
"TemporaryTopics": [],
"BrokerVersion": "5.13.2",
"AverageMessageSize": 1024,
"StorePercentUsage": 0,
"TemporaryQueueProducers": [],
"TotalEnqueueCount": 3,
"Persistent": true,
"TransportConnectors": {
"amqp": "amqp:\/\/NOTE140082:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600",
"mqtt": "mqtt:\/\/NOTE140082:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600",
"openwire": "tcp:\/\/NOTE140082:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600",
"ws": "ws:\/\/NOTE140082:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600",
"stomp": "stomp:\/\/NOTE140082:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"
},
"InactiveDurableTopicSubscribers": [],
"TemporaryTopicSubscribers": [],
"TemporaryQueueSubscribers": [],
"DynamicDestinationProducers": [],
"MemoryPercentUsage": 0,
"MemoryLimit": 726571418,
"Queues": [
{
"objectName": "org.apache.activemq:brokerName=localhost,destinationName=1111,destinationType=Queue,type=Broker"
},
{
"objectName": "org.apache.activemq:brokerName=localhost,destinationName=22222,destinationType=Queue,type=Broker"
}
],
"TotalConnectionsCount": 0,
"UptimeMillis": 82705502,
"DataDirectory": "E:\\apache-activemq-5.13.2\\data",
"TempLimit": 53687091200,
"JobSchedulerStoreLimit": 0,
"JobSchedulerStorePercentUsage": 0,
"SslURL": "",
"StatisticsEnabled": true,
"CurrentConnectionsCount": 0,
"JMSJobScheduler": null,
"TotalProducerCount": 0,
"MaxMessageSize": 1024,
"TempPercentUsage": 0
}
}
获取单个属性的值
http://localhost:8161/api/jolokia/read/org.apache.activemq:brokerName=localhost,type=Broker/BrokerId
http://localhost:8161/api/jolokia/read/org.apache.activemq:brokerName=localhost,type=Broker/ StompURL
搜索broker。
http://localhost:8161/api/jolokia/search/*:type=Broker,brokerName=*
这里可以用在初始获取broker信息的时候使用。因为如果activemq如果配置了jmxDomainName,<mbean name>就要写成:<jmxDomainName>:type,brokerName=。如果不配置默认是:org.apache.activemq。
<managementContext>
<managementContext createConnector="true" jmxDomainName="test.domain"/>
</managementContext>
http://localhost:8161/api/jolokia/read/test.domain:brokerName=localhost,type=Broker/BrokerId
这个能搜索所有的队列,包括队列的属性。但是如果当前没有队列,会返回错误。
通过broker的属性queues,只能拿到队列的名称列表,拿不到具体的队列属性。
http://localhost:8161/api/jolokia/read/test.domain:brokerName=localhost,type=Broker/Queues
jolokia官方在线文档:
https://jolokia.org/reference/html/index.html
jolokia官方pdf文档:
https://jolokia.org/reference/pdf/jolokia-reference.pdf