Soru

Zorluk: KolayImplement Azure Service Bus Solutions

A library book reservation system uses an Azure Service Bus queue to manage user reservation requests. The reservation system must process each request reliably. If a worker instance fails or restarts while processing a request, the request message must not be lost and must become available again in the queue so that another worker can pick it up.

Which option or method should you configure for the Service Bus receiver to satisfy this requirement?

  1. ServiceBusReceiveMode.PeekLockCevap
  2. B
    ServiceBusReceiveMode.ReceiveAndDelete
  3. C
    ServiceBusReceiver.PeekMessagesAsync
  4. D
    ServiceBusReceiver.DeferMessageAsync

Cevap

ServiceBusReceiveMode.PeekLock
The correct option is ServiceBusReceiveMode.PeekLock because it locks the message when retrieved, allowing the receiver to complete the processing. If the processing fails or the client crashes, the lock expires and the message is returned to the queue, ensuring no messages are lost.

Adım Adım Çözüm

1
Analyze the requirements for message processing reliability.
The application requires that a message must not be lost if a processing worker fails or restarts.
This tells us that a mechanism is needed to keep the message locked or in the queue until processing is explicitly confirmed as successful.
2
Evaluate the available receive modes and methods in Azure Service Bus.
ServiceBusReceiveMode.PeekLock locks the message on receipt without deleting it. ServiceBusReceiveMode.ReceiveAndDelete deletes the message immediately.
We must choose a mode that keeps the message in the queue during processing.
3
Select the correct mode based on the analysis.
ServiceBusReceiveMode.PeekLock is the correct mode because it prevents message loss by holding the message in a locked state until completed.
If the worker crashes, the lock will time out and the message will automatically become available for other workers again.

Anahtar Kavram

Azure Service Bus Receive Modes
Bu soruyu puanla