Implementing a FIFO Queue in Azure Service Bus | Microsoft AZ-101 Exam Answer

Implementing a FIFO Queue in Azure Service Bus

Question

You have an Azure Service Bus.

You need to implement a Service Bus queue that guarantees first-in-first-out (FIFO) delivery of messages.

What should you do?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D. E.

E

Through the use of messaging sessions you can guarantee ordering of messages, that is first-in-first-out (FIFO) delivery of messages.

https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-azure-and-service-bus-queues-compared-contrasted

The correct answer is E. Enable sessions.

In an Azure Service Bus, messages are delivered using a default round-robin distribution algorithm. This means that messages are delivered in a non-deterministic order, and there is no guarantee that the first message sent will be the first message received.

To implement a Service Bus queue that guarantees first-in-first-out (FIFO) delivery of messages, you need to enable sessions. Enabling sessions ensures that messages sent by a particular sender are delivered in the order they were sent. The session state is maintained for the sender, so messages are not interleaved with messages from other senders.

To enable sessions for a Service Bus queue, you can set the RequiresSession property of the queue to true. Once sessions are enabled, you can send messages to the queue with a SessionId property, which associates the message with a particular session.

Now, to go over the other options provided in the question:

A. Setting the Lock Duration setting to 10 seconds will not guarantee FIFO delivery of messages. Lock duration is the amount of time that a message is locked while it is being processed, to prevent other receivers from processing the message at the same time.

B. Enabling duplicate detection is useful when you want to ensure that a message is processed only once, even if it is received multiple times. This is not related to FIFO delivery of messages.

C. Setting the Max Size setting of the queue to 5 GB does not affect the order in which messages are delivered.

D. Enabling partitioning allows you to scale out a Service Bus queue across multiple message brokers, but it does not guarantee FIFO delivery of messages.

In summary, to implement a Service Bus queue that guarantees FIFO delivery of messages, you should enable sessions.