An online food delivery application uses Azure Service Bus queues to process customer orders. You are developing a C# application using the Azure.Messaging.ServiceBus SDK to receive and process these order messages. You need to ensure that the messages are processed reliably: they must not be deleted from the queue until processing succeeds, and they must be returned to the queue if the processing application crashes or fails. Which two configurations or actions should you implement to achieve this? (Select two.)
- Configure the receive mode to ServiceBusReceiveMode.PeekLock.Answer
- Call CompleteMessageAsync on the receiver or processor after the message is successfully processed.Answer
- CConfigure the receive mode to ServiceBusReceiveMode.ReceiveAndDelete.
- DCreate a Shared Access Signature (SAS) token at the Service Bus Namespace level with only Manage claims to authenticate the processor.
Answer
To ensure reliable processing, configure the receive mode to PeekLock and explicitly call CompleteMessageAsync on the receiver or processor after successful execution.
Reliable processing requires PeekLock mode so that the message is locked during execution. If processing succeeds, the application calls CompleteMessageAsync to finalize the process and delete the message. If the application crashes, the lock expires and the message becomes available again on the queue.
Step-by-Step Solution
Key Concept
Reliable message receiving modes in Azure Service Bus