A university course enrollment system uses an Azure Service Bus queue to process student registration requests. You are developing a C# console application that retrieves these requests. The application must guarantee that if the console application crashes during processing, the registration request is not lost and remains on the queue to be reprocessed by another instance. Which approach should you implement?
- Create a ServiceBusReceiver using ServiceBusReceiveMode.PeekLock and call CompleteMessageAsync after successfully processing the registration.Cevap
- BCreate a ServiceBusReceiver using ServiceBusReceiveMode.ReceiveAndDelete to process the registration requests.
- CConfigure a Shared Access Signature (SAS) token on the Service Bus namespace with Manage, Send, and Listen permissions for the application client.
- DGrant the application's system-assigned managed identity Key Vault secret get permissions to retrieve the Service Bus connection string.
Cevap
Create a ServiceBusReceiver using ServiceBusReceiveMode.PeekLock and call CompleteMessageAsync after successfully processing the registration.
Using the PeekLock receive mode ensures that the message is locked on the server side during processing but remains on the queue. If the application finishes processing successfully, it calls CompleteMessageAsync to delete the message. If the application crashes, the lock will expire, making the message available for other instances to process.
Adım Adım Çözüm
Anahtar Kavram
Azure Service Bus receive modes (PeekLock vs ReceiveAndDelete)