如何在Artemis中获得队列大小(深度) [英] How to get queue size (depth) in Artemis

查看:114
本文介绍了如何在Artemis中获得队列大小(深度)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Java客户端API,如何在远程ActiveMQ Artemis 2.4.0 代理中获取队列大小?

Using a Java client API, how can I get the queue size in a remote ActiveMQ Artemis 2.4.0 broker?

推荐答案

诸如统计信息之类的功能属于管理API.可以通过消息传递API通过HTTP(jolokia),JMX或JMX对其进行访问.

Such feature as stats belongs to the management API. It can be accessed over HTTP (jolokia), JMX or JMX via the messaging API.

官方文档中有一个示例足以阅读它. 为了方便起见,我会在这里背诵.

There is an example in the official documentation for users persistent enough to read it. I will recite it here for convenience.

ClientSession session = ...
ClientRequestor requestor = new ClientRequestor(session, "activemq.management");
ClientMessage message = session.createMessage(false);
ManagementHelper.putAttribute(message, "queue.exampleQueue", "messageCount");
session.start();
ClientMessage reply = requestor.request(m);
int count = (Integer) ManagementHelper.getResult(reply);
System.out.println("There are " + count + " messages in exampleQueue");

这篇关于如何在Artemis中获得队列大小(深度)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆