How do you support FIFO message orders using Azure Service Bus split queues / partitions?

I assume that the trade-off between partitioned queues and topics is that message ordering is no longer guaranteed.

As default messages send round-robin to each of the fragments / sections, this means that message ordering is no longer guaranteed. Can anyone confirm if this is the case?

How can you guarantee the ordering of messages when receiving transactions from a partitioned queue.

The only way to maintain ordering of FIFO messages with partitioned queues / themes to use sessions? I would suggest that all messages for the same session / section key will at least be delivered by FIFO?

+7
source share
3 answers

I found it blogged.

Hope this helps!

Shared Service Bus Queues and Topics

SessionId. If the message has the SessionId property, then the service bus uses the SessionId property as the section key. Thus, all messages related to the same session are assigned to the same fragment and are processed by the same message broker. This allows the service bus to guarantee message ordering as well as consistent session states.

+7
source

Just because you are not using a partitioned queue or topic does not mean that you will receive FIFO. If you have more than one reader or not async, then no, you will not get FIFO UNLESS if you use Session, as mentioned above. Please use the sessions.

+2
source

The answers above are missing an important point about FIFO.

When a message arrives in a topic / queue in which separation is not enabled, FIFO * is observed for message delivery.

When you enable separation for the topic / queue and SessionId is used for the separation key, then the messages are no longer guaranteed as FIFOs relative to each other, they are guaranteed to be only FIFOs in relation to the section in which they were divided to.

An interesting fact is that sharing as a whole can have some interesting side effects if you have a small number of subscribers to the same subscription / queue, as the partition reader assignments are done in a cyclic style, and if you have more sections than subscribers, you can see that the messages are exhausted (verification from the SB team is required, this is empirically from the tests that I conducted on my own because my messages were exhausted).


* As @Dan Rosanova pointed out above, if you have asynchronous processing or multiple readers, then your message processing cannot be guaranteed as FIFO, but the order in which messages were distributed between the handlers will be FIFO.

When you use the Session message handler (which requires filling in the SessionId), you take it one step further and ensure that the messages are processed in order, as the Session message handler blocks SessionId + MessageId and not just MessageId, thus ensuring that other processors do not will receive other messages in the same session.

0
source

Source: https://habr.com/ru/post/1211772/


All Articles