Microsoft Certified: Azure Developer Associate (AZ-204)Develop for Azure storageMedium
A manufacturing company uses Azure Queue Storage to process messages from factory sensors. Each message represents a sensor reading and must be processed exactly once, even if the processing worker fails. The worker application pulls messages, processes them, and then deletes them. What mechanism in Azure Queue Storage ensures that a message is not processed multiple times in case of a worker failure?
- ADequeue count
- BVisibility timeout
- CMessage expiration
- DPoison message handling
Show answer & explanationAnswer & explanation
Correct answer: B. Visibility timeout
When a message is dequeued from Azure Queue Storage, it becomes invisible for a specified 'visibility timeout' period. If the worker fails to delete the message within this period, it becomes visible again and can be processed by another worker, preventing duplicate processing during temporary failures but allowing retry if the original worker truly failed.
Why the other options are wrong
- A. Dequeue count tracks how many times a message has been dequeued, which is used for poison message detection, not for preventing immediate duplicates.
- C. Message expiration defines when a message is removed from the queue if not processed, not for preventing duplicates during processing.
- D. Poison message handling deals with messages that consistently fail to process, not the temporary prevention of duplicates during a single processing attempt.
Azure Queue Visibility Timeout
A duration during which a dequeued message is hidden from other consumers, preventing duplicate processing in distributed systems.
- Applied when a message is dequeued.
- If message is not deleted within timeout, it becomes visible again.
- Crucial for 'at-least-once' delivery and fault tolerance.
Memory trick: Visibility timeout is like a 'do not disturb' sign on a message for a short period.