ActiveMQ:通过JMX获取连接列表?
如何获取ActiveMQ OpenWire 连接器的连接列表? JConsole 能够列出连接,但我看不到可以使用哪个“视图”来获取列表:
连接的示例 ObjectName: org.apache.activemq:BrokerName=localhost,Type=Connection,ConnectorName=openwire,Connection=toto
我尝试了“ConnectorViewMBean”,但对其的操作不允许我列出连接:
ObjectName name = new ObjectName("org.apache.activemq:BrokerName=localhost,Type=Connection,ConnectorName=openwire");
mbsc.getMBeanInfo(name);
ConnectorViewMBean view = JMX.newMBeanProxy(mbsc, name, ConnectorViewMBean.class);
How do I get the list of the connections to the OpenWire connector of ActiveMQ?
JConsole is able to list the connections, but I don't see which "view" I can use to get the list:
Example ObjectName of a connection:org.apache.activemq:BrokerName=localhost,Type=Connection,ConnectorName=openwire,Connection=toto
I tried "ConnectorViewMBean", but the operations on it don't allow me to list the connections:
ObjectName name = new ObjectName("org.apache.activemq:BrokerName=localhost,Type=Connection,ConnectorName=openwire");
mbsc.getMBeanInfo(name);
ConnectorViewMBean view = JMX.newMBeanProxy(mbsc, name, ConnectorViewMBean.class);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我使用的是 ActiveMQ 5.14.5,它使用不同的 ObjectName 格式通过 JMX 查询连接。在此版本的 ActiveMQ 中,相当于 Andrew 的答案 是:
I'm using ActiveMQ 5.14.5, which uses a different ObjectName format for querying connections via JMX. The equivalent to Andrew's answer in this version of ActiveMQ is:
在最新版本的 ActiveMQ (5.1xx) 中,您可以使用 BrokerViewMBean 获取传输连接器的映射:
另请参阅 ConnectorViewMBean。
但是,虽然
BrokerViewMBean
中有一些方法可以获取传输连接器(如上面的代码所示),但没有任何方法可以获取网络(也称为代理到代理)连接器的列表。In the most recent versions of ActiveMQ (5.1x.x), you can use the BrokerViewMBean to get a map of transport connectors:
Check also out ConnectorViewMBean.
However, while there are methods in
BrokerViewMBean
to get transport connectors, as demonstrated in the above code, there aren't any to get a list of network (a.k.a. broker-to-broker) connectors.解决方案是使用表达式:
The solution was the usage of an expression: