You are developing a C# background service that processes flight ticket booking transactions from an Azure Service Bus queue. Each booking transaction involves multiple external API calls to airlines and payment gateways, which takes up to 90 seconds to complete under peak load. If the service crashes or loses connectivity while processing a booking, the transaction message must not be lost and must be made available for reprocessing by another service instance. You need to configure the `ServiceBusProcessor` using the C# Azure SDK (`Azure.Messaging.ServiceBus`). Which configuration settings must you apply to meet these requirements?
- Configure ServiceBusProcessorOptions with ReceiveMode set to ServiceBusReceiveMode.PeekLock and MaxAutoLockRenewalDuration set to 2 minutes.Cevap
- BConfigure ServiceBusProcessorOptions with ReceiveMode set to ServiceBusReceiveMode.ReceiveAndDelete and MaxAutoLockRenewalDuration set to 2 minutes.
- CConfigure ServiceBusProcessorOptions with ReceiveMode set to ServiceBusReceiveMode.PeekLock and AutoCompleteMessages set to false, without calling CompleteMessageAsync in the message handler.
- DConfigure ServiceBusProcessorOptions with ReceiveMode set to ServiceBusReceiveMode.ReceiveAndDelete and AutoCompleteMessages set to true.
Cevap
Configure ServiceBusProcessorOptions with ReceiveMode set to ServiceBusReceiveMode.PeekLock and MaxAutoLockRenewalDuration set to 2 minutes.
The correct configuration uses PeekLock mode to guarantee that the message is not lost if processing fails, and sets MaxAutoLockRenewalDuration to 2 minutes to ensure the processor maintains the lock for the duration of the 90-second operation.
Adım Adım Çözüm
Anahtar Kavram
Message locking and settlement modes in Azure Service Bus SDK