A digital ticketing platform processes high-value concert ticket bookings using an Azure Service Bus queue. To prevent booking failures, the system must guarantee that if a processing instance crashes during the checkout transaction, the message is not lost and remains available in the queue for another instance to process. Which message receive mode and SDK action should you implement?
- Receive messages using PeekLock mode, perform the checkout logic, and then call CompleteMessageAsync.Answer
- BReceive messages using ReceiveAndDelete mode, perform the checkout logic, and then call CompleteMessageAsync.
- CReceive messages using PeekLock mode, which automatically deletes the message from the queue immediately upon retrieval.
- DReceive messages using ReceiveAndDelete mode, and call AbandonMessageAsync if the processing instance crashes.
Answer
Receive messages using PeekLock mode, perform the checkout logic, and then call CompleteMessageAsync.
Receiving messages using PeekLock mode ensures that the message is locked but remains in the queue. Only after successful processing is CompleteMessageAsync called to permanently delete the message. If a crash occurs, the lock expires, making the message available for other instances to process.
Step-by-Step Solution
Key Concept
Azure Service Bus receive modes: PeekLock vs ReceiveAndDelete.
Estimated Time:1m 30s