Question

Difficulty: EasyImplement Azure Service Bus Solutions

A digital publishing company is building a newsletter distribution system. They use an Azure Service Bus queue named `newsletter-campaigns` to manage subscriber email campaigns. They require that if a sending service instance fails while processing a newsletter message, the message must be automatically returned to the queue so that another instance can attempt to process it.

Which configuration or method should you use to meet this requirement?

  1. A
    Configure the receiver to use `ServiceBusReceiveMode.ReceiveAndDelete`.
  2. Configure the receiver to use `ServiceBusReceiveMode.PeekLock`.Answer
  3. C
    Call `PeekMessagesAsync` on the receiver to retrieve and process the messages.
  4. D
    Set the `RequiresSession` property on the queue to `true`.

Answer

Configure the receiver to use ServiceBusReceiveMode.PeekLock.
Configuring the receiver to use PeekLock mode is correct because it ensures that messages are locked during processing but remain in the queue. If the receiver fails or crashes before completing the message, the lock will time out and the message will automatically become available for processing again.

Step-by-Step Solution

1
Analyze the reliability requirement for the newsletter application.
The application requires that messages must not be lost if a receiver fails during processing, meaning at-least-once delivery is required.
Understanding the delivery guarantee is necessary to select the appropriate message receipt mode.
2
Compare Azure Service Bus receive modes for message processing.
PeekLock mode retrieves the message and locks it temporarily without deleting it, while ReceiveAndDelete mode deletes the message immediately from the queue upon retrieval.
This comparison helps identify which mode protects messages against receiver failures.
3
Select the configuration that guarantees message recovery.
Configuring the receiver to use ServiceBusReceiveMode.PeekLock ensures the message returns to the queue if the receiver fails before completing the processing.
This satisfies the requirement of returning the message to the queue for another instance to process.

Key Concept

Azure Service Bus receive modes (PeekLock vs. ReceiveAndDelete) and their impact on message durability and delivery guarantees.
Estimated Time:45s
Rate this question