Soru

Zorluk: ZorImplement Azure Service Bus Solutions

You are developing a .NET background worker service that processes media rendering tasks from an Azure Service Bus queue. The rendering tasks are computationally intensive and take between 2 to 4 minutes to complete. The queue's default lock duration is set to 30 seconds. You must ensure that tasks are not processed by multiple workers concurrently, and if a worker crashes during processing, the task must be returned to the queue without message loss. Which configuration strategy should you implement?

  1. Initialize the ServiceBusProcessor in PeekLock mode, and set the MaxAutoLockRenewalDuration property in ServiceBusProcessorOptions to 5 minutes.Cevap
  2. B
    Initialize the ServiceBusProcessor in ReceiveAndDelete mode to instantly remove the message from the queue, preventing lock expiration issues.
  3. C
    Generate a Service Bus namespace Shared Access Signature (SAS) token with Manage permissions to allow the background worker code to dynamically update the queue's default lock duration property during message execution.
  4. D
    Configure the background worker to authenticate using a user-assigned managed identity instead of a system-assigned managed identity to automatically increase the default lock duration to 5 minutes.

Cevap

Initialize the ServiceBusProcessor in PeekLock mode, and set the MaxAutoLockRenewalDuration property in ServiceBusProcessorOptions to 5 minutes.
The correct answer demonstrates how to handle long-running message processing safely in Azure Service Bus. By retaining PeekLock mode, messages are protected from loss if the worker fails. Configuring the MaxAutoLockRenewalDuration property in the ServiceBusProcessorOptions allows the background SDK client to renew the lock periodically up to the specified limit (5 minutes), preventing other workers from picking up the message while it is still being processed.

Adım Adım Çözüm

1
Select the correct message consumption mode.
PeekLock mode is chosen because it ensures transactional safety by locking the message during processing rather than deleting it immediately.
Preventing message loss upon application crash requires PeekLock mode so that uncompleted messages return to the queue.
2
Address the 30-second lock limit for a 2-4 minute task.
Configure automatic lock renewal via ServiceBusProcessorOptions.
If the lock expires, other instances of the worker can consume the same message, causing duplicate processing. Enabling MaxAutoLockRenewalDuration lets the client SDK handle lock extensions automatically.
3
Define the renewal duration boundary.
Set MaxAutoLockRenewalDuration to 5 minutes (which is greater than the maximum 4-minute processing time).
The renewal duration must cover the maximum expected duration of the long-running process.

Anahtar Kavram

Azure Service Bus message locking mechanics, receiver modes, and automatic lock renewal properties inside the .NET SDK.
Tahmini Süre:2m 0s
Bu soruyu puanla