Soru

Zorluk: OrtaImplement Azure Service Bus Solutions

A digital ticketing platform processes high-value concert ticket bookings using an Azure Service Bus queue. To prevent booking failures, the system must guarantee that if a processing instance crashes during the checkout transaction, the message is not lost and remains available in the queue for another instance to process. Which message receive mode and SDK action should you implement?

  1. Receive messages using PeekLock mode, perform the checkout logic, and then call CompleteMessageAsync.Cevap
  2. B
    Receive messages using ReceiveAndDelete mode, perform the checkout logic, and then call CompleteMessageAsync.
  3. C
    Receive messages using PeekLock mode, which automatically deletes the message from the queue immediately upon retrieval.
  4. D
    Receive messages using ReceiveAndDelete mode, and call AbandonMessageAsync if the processing instance crashes.

Cevap

Receive messages using PeekLock mode, perform the checkout logic, and then call CompleteMessageAsync.
Receiving messages using PeekLock mode ensures that the message is locked but remains in the queue. Only after successful processing is CompleteMessageAsync called to permanently delete the message. If a crash occurs, the lock expires, making the message available for other instances to process.

Adım Adım Çözüm

1
Select PeekLock receive mode for the Service Bus client/receiver.
The message is retrieved from the queue and locked for a specified duration, preventing other receivers from processing it while keeping it in the queue.
Ensures that if the receiver crashes, the message remains in the queue and can be reprocessed when the lock expires.
2
Execute the ticket checkout logic.
The booking transaction is completed successfully.
Verifies that the message has been successfully processed before removing it from the system.
3
Invoke CompleteMessageAsync on the receiver passing the message.
The message is permanently deleted from the queue.
Signals to Azure Service Bus that processing was successful and the message can be safely removed.

Anahtar Kavram

Azure Service Bus receive modes: PeekLock vs ReceiveAndDelete.
Tahmini Süre:1m 30s
Bu soruyu puanla