0
votes

I have configured two brokers A and B using networkconnectors. Is the message order preserved if I am using exclusive consumer (single consumer) or message groups(JMXgroupID)?

In the network of broker documentation I found this:

Total message ordering is not preserved with networks of brokers. Total ordering works with a single consumer but a networkBridge introduces a second consumer. In addition, network bridge consumers forward messages via producer.send(..), so they go from the head of the queue on the forwarding broker to the tail of the queue on the target. If single consumer moves between networked brokers, total order may be preserved if all messages always follow the consumer but this can be difficult to guarantee with large message backlogs.

In single broker message ordering is possible through exclusive consumer. What will happen if I am using network of brokers with exclusive consumers?

1
Did my answer address your question? If so, please mark it as correct to help other users who have this same question in the future. If not, please elaborate as to why. Thanks!Justin Bertram

1 Answers

2
votes

Total message ordering in a network of brokers doesn't work - even if you have a single consumer or multiple consumers using the "exclusive consumer" feature.

Consider the following scenario with 2 brokers (let's call these broker-A & broker-B) in a network, 1 consumer (consumer-A), 2 producers (producer-A & producer-B), and 1 queue (queue-A).

  1. producer-A connects to broker-A, sends a message (message-1) to queue-A, and disconnects.
  2. producer-B connects to broker-B, sends a message (message-2) to queue-A, and disconnects.
  3. producer-A reconnects to broker-A, sends a message (message-3) to queue-A, and disconnects.
  4. consumer-A connects to broker-A and receives the messages from queue-A. Even though the messages were sent in order message-1, message-2, message-3 the consumer will actually receive the messages in the order message-1, message-3, message-2 because message-1 and message-3 were sent to broker-A and message-2 was sent to broker-B and had to be moved across the network of brokers to broker-A based on consumer demand.

It's worth noting that one of the main goals of a network of brokers is scalability. However, in order to guarantee messages are consumed in order the messages have to be consumed serially which can drastically reduce performance and would almost certainly nullify any scalability gains provided by the network of brokers. Total message ordering and a network of brokers are fundamentally opposed ideas. If you really want total message ordering you shouldn't use a network of brokers.