Message Order in Apache ActiveMQ Artemis Cluster

1.2k Views Asked by At

I am trying to implement message ordering in Apache Artemis cluster. Producers/Consumers connecting to the cluster implement High availability. So at one point of time there will be two instances of same application connecting to topic or queue. So far, I could find following two methods which can be used to achieve ordering in Red Hat AMQ / Artemis cluster:

  1. Message Groups (is reliable only when there is one consumer per node in the cluster as per the documentation)
  2. Exclusive Queues (Message order is preserved only on a single node).

I fully understand using cluster and expecting message ordering are conflicting requirements, but its still a requirement to be implemented in the project I am working on as the consumers are unable to handle the complexity of handling out of order messages.

What are the alternatives to the above that can be used to implement message ordering in Artemis ActiveMQ / Red Hat AMQ Cluster?

1

There are 1 best solutions below

4
On

In a clustered environment an exclusive consumer is tied to each queue on each broker, so depending on the message load balancing configuration, you could have one consumer per broker receiving messages. This breaks ordering. Your producer and consumers need to be on the same broker instance to preserve ordering.

As you say, clustered message groups functionality is not reliable, nevertheless it may be useful in some, very specific use cases. Also note that, for HA it's not sufficient to have a cluster of brokers. You need to explicitly configure HA (shared-store or replication), otherwise, if a broker fails permanently, then all its messages would be lost.