A healthcare provider uses an Azure Service Bus queue named `patient-checkins` to manage incoming patient arrival data. You are writing a C# client using the Azure.Messaging.ServiceBus SDK to retrieve and process these messages. You must ensure that messages are only removed from the queue after they have been successfully processed, preventing message loss if the client application crashes during execution. Which configuration or approach should you implement?
- Initialize the `ServiceBusReceiver` with `ServiceBusReceiveMode.PeekLock` and call `CompleteMessageAsync` after the message is successfully processed.Cevap
- BInitialize the `ServiceBusReceiver` with `ServiceBusReceiveMode.ReceiveAndDelete` to automatically handle message removal upon retrieval.
- CGrant the client application's system-assigned managed identity a Key Vault Access Policy with secret retrieval permissions, without assigning any Azure Service Bus RBAC roles.
- DConnect to the queue using a Shared Access Signature (SAS) token configured with namespace-level Manage claims.
Cevap
Initialize the `ServiceBusReceiver` with `ServiceBusReceiveMode.PeekLock` and call `CompleteMessageAsync` after the message is successfully processed.
The correct answer is to use `ServiceBusReceiveMode.PeekLock` and call `CompleteMessageAsync` after processing. In PeekLock mode, the receiver locks the message on the queue for a specified duration, allowing the receiver to complete the message once successfully processed. If the receiver crashes, the lock expires, and the message becomes available to other receivers again, preventing loss.
Adım Adım Çözüm
Anahtar Kavram
Azure Service Bus Receive Modes and Message Settlement