简体   繁体   English

JMS消息计数器

[英]JMS Message Counter

I would like to display JMS queue statistics on the page where I may present how many messages are in the queues 我想在页面上显示JMS队列统计信息,我可以在其中显示队列中有多少消息

Is there any way to do that in universal way (without using any provider specific API) whithout iterating through all messages? 有没有办法以通用方式(不使用任何提供者特定的API)执行此操作而不迭代所有消息?

I know that I may achive that using QueueBrowser.getEnumeration() however it is too costly to iterate over all messages just for simple counting functionality. 我知道我可能会使用QueueBrowser.getEnumeration(),但是为了简单的计数功能而迭代所有消息的成本太高。

I see no reference to statistics in the JMS 1.1 spec . 我没有看到JMS 1.1规范中的统计信息。

My experience w/ statistics is that they're available through vendor-specific interfaces. 我的统计数据是,它们可以通过特定于供应商的界面获得。

I do not believe that it is possible in the manner you seek. 我不相信你寻求的方式是可能的。

Although your question specifically asks about non-provider specific methods I will offer this: 虽然您的问题专门询问非提供商的具体方法,但我会提供:

ActiveMQ can be monitored via JMX which allows you to interrogate many things including queue size. 可以通过JMX监视ActiveMQ ,它允许您查询包括队列大小在内的许多内容。 You can always create an interface which you can then extend on a per-provider basis (and as an example you would retrieve queue size from an ActiveMQ provider implementation via JMX). 您始终可以创建一个接口,然后可以基于每个提供程序进行扩展(例如,您将通过JMX从ActiveMQ提供程序实现中检索队列大小)。

QueueBrowser is the only standard way of browsing messages in a Queue without consuming them. QueueBrowser是浏览队列中消息而不消耗它们的唯一标准方法。

Sorry about that. 对于那个很抱歉。

This solution is specific to WebLogic, and it uses JMSDestinationRuntimeMBean, but every Application Server should allow you to do something equivalent: 此解决方案特定于WebLogic,它使用JMSDestinationRuntimeMBean,但每个Application Server都应允许您执行等效的操作:

http://www.javamonamour.org/2012/01/counting-jms-messages-present-in-jms.html http://www.javamonamour.org/2012/01/counting-jms-messages-present-in-jms.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM