A digital publishing company is building a newsletter distribution system. They use an Azure Service Bus queue named `newsletter-campaigns` to manage subscriber email campaigns. They require that if a sending service instance fails while processing a newsletter message, the message must be automatically returned to the queue so that another instance can attempt to process it.
Which configuration or method should you use to meet this requirement?
- AConfigure the receiver to use `ServiceBusReceiveMode.ReceiveAndDelete`.
- Configure the receiver to use `ServiceBusReceiveMode.PeekLock`.Answer
- CCall `PeekMessagesAsync` on the receiver to retrieve and process the messages.
- DSet the `RequiresSession` property on the queue to `true`.
Answer
Configure the receiver to use ServiceBusReceiveMode.PeekLock.
Configuring the receiver to use PeekLock mode is correct because it ensures that messages are locked during processing but remain in the queue. If the receiver fails or crashes before completing the message, the lock will time out and the message will automatically become available for processing again.
Step-by-Step Solution
Key Concept
Azure Service Bus receive modes (PeekLock vs. ReceiveAndDelete) and their impact on message durability and delivery guarantees.
Estimated Time:45s