Clustering is a large area and often means different things to different people. We'll try to list the various aspects of clustering and how they relate to ActiveMQ
Queue consumer clusters
We support ActiveMQ supports reliable high performance load balancing of messages on a queue across consumers. If a consumer dies, any unacknowledged messages are redelivered to other consumers on the queue. If one consumer is faster than the others it gets more messages etc. If any consumer slows down, other consumers pick up the slack. So you can have a reliable load balanced cluster of consumers on a queue processing messages.Using queues in this way, possibly across a network of brokers (see below) provides a good grid style processing model, allowing a cluster of worker processes to asynchronously process messages placed on a queue in a scalable and efficient SEDA style manner. Many folks often want a grid solution to allow server farms to process various tasks like complex calculations and so forth - mostly an ActiveMQ network of brokers and clients with failover:// transport will do the trickIn enterprise integration, this scenario is known as the competing consumers pattern. The following figure illustrates the concept:
Image Added
This solution will receive the messages sent by the producers, enqueue them and distribute them between all the registered consumers. This has a number of benefits:
- The load is distrubuted in a very dynamic fashion. Consumers could be provisioned and attached to the queue in high load periods, without modifying any configuration in the queue, as the new consumier will behave as just another competing consumer.
- Better availability than systems using a load balancer. Load balancers usually rely on a monitorization system to find out which real-servers are unavailable. With competing consumers a failed consumer won't be competing for messages and therefor messages won't be delivered to it even without monitorization.
- High reliability, if a consumer dies, any unacknowledged messages are redelivered to other consumers on the queue.
On the downside, this pattern might not be ideal in systems where the ordered processing is required. To mitigate this problem while maintaining the benefits, the competing consumers pattern should be used in conjuntion with other ActiveMQ features like the exclusive consumers and the message groups.
Broker clusters
The most common mental model of clustering in a JMS context is that there is a collection of JMS brokers and a JMS client will connect to one of them; then if the JMS broker goes down, it will auto-reconnect to another broker.
...