Chapter 13. Tuning ActiveMQ for performance
ActiveMQ performance depends on the broader environment, including network design, transport choices, hardware, operating system, and the JVM, but the chapter emphasizes that there are also practical tuning steps that can help in almost any deployment. The most important theme is to reduce unnecessary work: avoid persistence when guaranteed delivery is not required, batch messages when transactions make sense, and consider embedding the broker with the application to reduce serialization and network overhead. The chapter frames tuning as a balance between speed, reliability, and the costs of moving data through the broker.
Several core configuration areas are explored. On the broker and transport side, the text explains how OpenWire and TCP settings can influence throughput, especially for small messages or slower networks, with options such as caching, buffer sizing, and TCP no-delay behavior. On the producer side, asynchronous sending can improve throughput even for persistent messages, while producer flow control protects broker resources but may slow applications unless tuned with limits or timeout-based failure behavior. On the consumer side, prefetch settings, dispatch strategy, and acknowledgment behavior have major impact: larger prefetch can increase speed, message listeners are faster than synchronous receive calls, and batched acknowledgments such as optimizeAcknowledgement can significantly improve consumption rate.
The chapter then pulls these ideas together in a real-time data feed example that uses an embedded broker, nonpersistent producer delivery, disabled message copying, disabled producer flow control, a high consumer prefetch limit, and optimized acknowledgments. This example illustrates the central lesson that the fastest ActiveMQ applications are usually those that minimize persistence, reduce coordination overhead, and keep producers and consumers from blocking one another unnecessarily. At the same time, the chapter repeatedly warns that every performance gain comes with tradeoffs such as possible duplicates, reduced durability, or greater memory use, so tuning should always reflect the needs of the application rather than chasing speed alone.
Confirmation of persistent message delivery in ActiveMQ
Embedding an ActiveMQ broker with a service
MessageProducer feedback with producer flow control enabled
What the broker does with producer flow control disabled
How messages are passed through an ActiveMQ connection to a MessageConsumer in multiple steps using multiple threads
Optimized message passing to a message consumer in an ActiveMQ connection with alwaysSessionAsync=false
The sample tuned data feed application
ActiveMQ in Action ebook for free