이 콘텐츠는 선택한 언어로 제공되지 않습니다.

28.6. Message Counters


Message counters can be used to obtain information on queues over time as HornetQ keeps a history of queue metrics.
They can be used to show trends on queues. For example, using the management API, it would be possible to query the number of messages in a queue at regular intervals. You could also view this information using the JMX Console, or use the core API (org.hornetq.api.core.management.MessageCounterInfo) to extract the information.
However, this would not be enough to know if the queue is used. The number of messages can remain constant because nobody is sending or receiving messages from the queue or because there are as many messages sent to the queue as messages consumed from it. The number of messages in the queue remains the same in both cases but its use is different.
Message counters provide additional information about the queues:
count
The total number of messages added to the queue since the server was started.
countDelta
The number of messages added to the queue since the last message counter update.
depth
The current number of messages in the queue.
depthDelta
The overall number of messages added or removed from the queue since the last message counter update. For example, if depthDelta is equal to -10 this means that overall 10 messages have been removed from the queue.
lastAddTimestamp
The time stamp of the last time a message was added to the queue.
udpateTimestamp
The time stamp of the last message counter update.

28.6.1. Configuring Message Counters

Message counters are disabled by default as they could have a negative effect on memory.
To enable message counters, you can set it to true in <JBOSS_HOME>/jboss-as/server/<PROFILE>/deploy/hornetq/hornetq-configuration.xml:
<message-counter-enabled>true</message-counter-enabled>
Copy to Clipboard Toggle word wrap
Message counters keep a history of the queue metrics (10 days by default) and sample all the queues at regular intervals (10 seconds by default). If message counters are enabled, these values should be configured to suit your messaging use case in <JBOSS_HOME>/jboss-as/server/<PROFILE>/deploy/hornetq/hornetq-configuration.xml:
<!-- keep history for a week -->
<message-counter-max-day-history>7</message-counter-max-day-history>        
<!-- sample the queues every minute (60000ms) -->
<message-counter-sample-period>60000</message-counter-sample-period>
Copy to Clipboard Toggle word wrap
Message counters can be retrieved using the Management API. For example, to retrieve message counters on a JMS Queue using JMX:
// retrieve a connection to HornetQ's MBeanServer
MBeanServerConnection mbsc = ...
JMSQueueControlMBean queueControl = (JMSQueueControl)MBeanServerInvocationHandler.newProxyInstance(mbsc,
   on,
   JMSQueueControl.class,
   false);
// message counters are retrieved as a JSON String                                                                                                      
String counters = queueControl.listMessageCounter();
// use the MessageCounterInfo helper class to manipulate message counters more easily
MessageCounterInfo messageCounter = MessageCounterInfo.fromJSON(counters);         
System.out.format("%s message(s) in the queue (since last sample: %s)\n",
   counter.getDepth(),
   counter.getDepthDelta());
Copy to Clipboard Toggle word wrap
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat