A food delivery platform dispatch system uses Azure Service Bus to process orders for multiple restaurants. The system must guarantee that orders for each restaurant are processed in the exact order they are received. Additionally, if the consumer application crashes during processing, the message must not be lost and should eventually be moved to the dead-letter queue after a specific number of retries. Which two configuration or implementation steps should you perform to meet these requirements? (Select two.)
- Enable sessions on the queue and set the SessionId property on each ServiceBusMessage to the restaurant's unique identifier.Answer
- Use the ServiceBusSessionProcessor to read messages and call CompleteMessageAsync on the receiver after successful processing of a message.Answer
- CConfigure the receiver to use ReceiveAndDelete mode to ensure that messages that fail processing are automatically routed to the dead-letter queue.
- DCreate a Shared Access Signature (SAS) token with Manage permissions at the namespace level to authenticate the consumer application.
Answer
Enable sessions on the queue and set the SessionId property on each ServiceBusMessage to the restaurant's unique identifier, and use the ServiceBusSessionProcessor to read messages and call CompleteMessageAsync after successful processing.
To achieve FIFO ordering per restaurant, you must enable sessions on the queue and assign the SessionId property on outgoing messages to the restaurant's identifier. To prevent message loss in case of processing crashes, you must use PeekLock mode (implicitly used by ServiceBusSessionProcessor when calling CompleteMessageAsync explicitly after processing) so that incomplete messages are returned to the queue and eventually dead-lettered after the maximum delivery count is reached.
Step-by-Step Solution
Key Concept
Azure Service Bus Sessions and Message Lock Modes