To monitor ActiveMQ performance in Spring Boot, track two sides: the broker (queue depth, enqueue and dequeue counts, consumer count, memory usage) through JMX or a Prometheus exporter, and your application (listener throughput, processing time, failures) through Micrometer metrics exposed by Spring Boot Actuator. Prometheus scrapes both and Grafana plots them.
Broker metrics tell you that messages are piling up. Application metrics tell you why. You need both to separate a slow consumer from a stalled one or from a producer that is simply too fast.
Whether you run ActiveMQ Classic or ActiveMQ Artemis, watch the same signals per destination:
| Signal | What a problem looks like |
|---|---|
| Queue size (depth) | Grows steadily: consumers are slower than producers or have stopped |
| Enqueue count rate | Sudden jump or drop: producer burst or upstream failure |
| Dequeue count rate | Flat while enqueue rises: consumers are stuck |
| Consumer count | Zero on a queue that should have consumers |
| Memory usage percent and store usage percent | Near the limit: the broker slows down or blocks producers (flow control) |
| Dead letter queue (DLQ) size | Any growth: messages keep failing after redelivery |
| Expired and redelivered counts | High values: poison messages or time-to-live too short |
Alert on trends, such as queue depth rising for several minutes, not on single samples.
ActiveMQ exposes its statistics as MBeans. In ActiveMQ Classic, JMX is enabled by default through useJmx="true" on the broker element in conf/activemq.xml (the management connector is configured in the same file). You can browse the beans with JConsole or VisualVM under org.apache.activemq. Artemis publishes similar MBeans under org.apache.activemq.artemis, and its web console and Jolokia endpoint give HTTP access to the same data.
For a quick manual check, the web console on port 8161 shows queues, pending messages, consumers and enqueued and dequeued counts without any extra setup. Secure it and do not expose it publicly.
JMX is not a format Prometheus can read, so use one of these:
-javaagent on the broker JVM with a YAML file that maps MBean attributes to metric names. It works with Classic and Artemis.artemis-prometheus-metrics-plugin module), which serves metrics over HTTP in Prometheus format. Check the Artemis documentation for the version you run.Then add a scrape job:
Import or build a Grafana dashboard with panels for queue depth, enqueue and dequeue rates, consumers, and memory usage. Use rate-based queries such as rate(...[5m]) for counters.
Add Actuator and a Prometheus registry to the Spring Boot application:
/actuator/prometheus now serves JVM, HTTP and connection pool metrics. Spring Boot's JMS auto-configuration does not publish per-queue broker statistics, so add your own meters around the listener:
Rethrowing keeps the JMS redelivery policy working, so failed messages are retried and eventually reach the dead letter queue. The timer gives you latency percentiles per consumer instance, and the counters give an error ratio.
If you cannot run an exporter, read the broker's JMX bean from the application and register a gauge. This example reads the queue size of a Classic broker over remote JMX (the broker must expose a JMX port that your application can reach and authenticate to):
Opening a connection on every scrape is acceptable for a few queues but wasteful at scale. For many destinations, prefer the JMX Exporter on the broker. MBean names and attributes differ in Artemis, so check them in JConsole first.
Spring Boot registers a JMS health indicator when a connection factory is present, so /actuator/health reports whether the application can reach the broker. Add Prometheus alert rules for the symptoms from the table above, for example queue depth above a threshold for 10 minutes, zero consumers on a critical queue, or DLQ size greater than zero. Keep Actuator on a separate management port (management.server.port) and behind authentication.
No. Actuator exposes JVM, HTTP and connection metrics, and a JMS health check. Queue depth comes from the broker through JMX, an exporter, or a gauge you register yourself.
Artemis is the ActiveMQ project's next-generation broker, and new projects usually start there. Spring Boot has supported both through separate starters, but check the release notes for your Boot version, because Classic support has changed over time.
Alert when the dequeue rate is zero while queue depth is above zero, or when the consumer count drops to zero. Compare with your listener's processed counter.
Open the broker web console for a manual view, add Actuator with a Prometheus endpoint for application metrics, then add the JMX Exporter when you need history and alerts.
Monitor ActiveMQ from both ends. Export broker statistics (queue depth, enqueue and dequeue rates, consumers, memory, DLQ) through JMX with the JMX Exporter or the Artemis Prometheus plugin, and record listener timers and counters with Micrometer in the Spring Boot application. Scrape both with Prometheus, chart them in Grafana, and alert on sustained trends rather than single values.