I have a single node ActiveMQ instance with two competing consumers connected to a topic. The topic subscription is shared as per JMS 2.0 specification. Shared subscription does guarantee that only either of the subscribers (using same subscription name) gets the message. But what I noticed is that it does not guarantee that the second message is delivered only if the first one is acknowledged. In case if the first consumer takes time to acknowledge the message, the second message is delivered to the free consumer even before the acknowledgement of the first one is sent by the consumer to the broker. Is this a standard behaviour? And is there a way to stop the broker from delivering the second message before the acknowledgement of the first one?
Asked
Active
Viewed 733 times
0
-
2What you're seeing is standard behavior. One of the main reasons (if not the only reason) shared subscriptions were added to the spec was to allow for load balancing. If order was strictly enforced that would defeat the purpose of load balancing in the first place. Concurrent processing will always introduce the possibility of out-of-order processing. – Justin Bertram Mar 11 '21 at 15:10
1 Answers
2
ActiveMQ Artemis allows the exclusive queues. They are special queues which route all messages to only one consumer at a time. Obviously exclusive queues have a draw back that you cannot scale out the consumers to improve consumption as only one consumer would technically be active.
However I would suggest to take a look at the message grouping to scale out your solution. Message groups are useful when you want all messages for a certain value of the property to be processed serially by the same consumer, without stopping the delivery of messages with different value of the property to other consumers.

Domenico Francesco Bruscino
- 1,775
- 7
- 9
-
Exclusive queues are not supported in a cluster. Is there an option to use exclusive queues in cluster? – akki Mar 11 '21 at 08:54
-
Your question says you have, "a single node ActiveMQ instance," no? You already asked about ordering in a cluster in [this question](https://stackoverflow.com/questions/66203165/message-order-in-apache-activemq-artemis-cluster). – Justin Bertram Mar 11 '21 at 14:11