activemq-artemis/examples/features/standard/message-counters
Clebert Suconic 784aa9f884 [maven-release-plugin] prepare for next development iteration 2023-09-14 16:54:07 -04:00
..
src/main NO-JIRA Updating activemq.org links 2021-12-20 14:46:01 -05:00
pom.xml [maven-release-plugin] prepare for next development iteration 2023-09-14 16:54:07 -04:00
readme.md ARTEMIS-1562 Refactor example documentation 2017-12-15 14:54:16 +00:00

readme.md

JMS Message Counter Example

To run the example, simply type mvn verify from this directory, or mvn -PnoServer verify if you want to start and create the broker manually.

This example shows you how to use message counters to obtain message information for a JMS queue.

The example will show how to configure sampling of message counters.

We will produce and consume 1 message from a queue. Interleaved with the JMS operation, we will retrieve the queue's message counters at different times to display the metrics on the queue.

Example setup

Message counter is configured in the broker configuration file broker.xml:

<message-counter-enabled>true</message-counter-enabled>
<message-counter-sample-period>2000</message-counter-sample-period>
<message-counter-max-day-history>2</message-counter-max-day-history>

By default, message counters are not enabled (for performance reason). To enable them, set message-counter-enabled to true. Queues are sampled every 10 seconds by default. For this example we will reduce it to 2 seconds by setting message-counter-sample-period to 2000. ActiveMQ Artemis holds in memory the message counters' history for a maximum number of days (10 by default). We can change the number of days the history is kept by setting the message-counter-max-day-history parameter.

The sample period and the max day history parameters have a small impact on the performance of ActiveMQ Artemis (the resources taken to sample a queue are not available to the system's normal use). You should set these parameters accordingly to the use and throughput of your messages.