Integration / ActiveMQ Interview Questions Intermediate
How do you troubleshoot slow consumers in ActiveMQ?
Start with the web console or JMX to check the queue's pending message count and consumer count - a steadily growing backlog with an active consumer usually means the consumer's processing logic, not the broker, is the bottleneck.
Check the prefetch limit: a high prefetch can let one consumer hold a large local batch of messages while barely working through them, starving other consumers on the same queue. Look at consumer-side logs and thread dumps for blocking calls, like slow database queries or external API timeouts, inside the message listener. If the slowness is intermittent, correlate it with GC pauses on the consumer JVM. Once diagnosed, fixes usually involve lowering prefetch, adding more consumer instances, moving heavy work off the listener thread into an async pool, or splitting the queue by message type so slow and fast work don't share the same backlog.
It also helps to rule out network-level causes, like a saturated link between broker and consumer host, before assuming the bottleneck is purely application code.
More Related questions...