Service Bus duplicate detection and OrderId sessions

AI-200 By islever Editorial Last updated

Short answer

C Duplicate detection with a 10-minute window suppresses repeated order submissions, and OrderId-keyed sessions serialize each order's messages for in-order processing.

Question

An order-processing pipeline must guarantee that duplicate submissions (same OrderId sent twice within 10 minutes) are not processed twice, and that messages for the same OrderId are handled in order. Which Service Bus configuration meets both needs?
  1. Use ReceiveAndDelete mode with prefetch
  2. Enable partitioning and set a large max size
  3. Enable duplicate detection with a 10-minute window and use sessions keyed by OrderId Correct Answer
  4. Use Event Grid with retries

Key Takeaways

Azure Service Bus duplicate detection combined with sessions is the configuration that both suppresses repeated order submissions and preserves per-order sequencing. The correct option, C, enables a 10-minute duplicate-detection window and keys a session-enabled queue or subscription by OrderId, so one consumer processes each order's messages in order. Partitioning, ReceiveAndDelete with prefetch, and Event Grid retries address scale, delivery, or fan-out but do not supply both guarantees.

Expert Analysis

Duplicate detection with a 10-minute window discards repeated MessageIds within that window, and sessions keyed by OrderId enforce ordered, single-consumer processing per order — together satisfying both requirements. Partitioning/max size addresses scale, ReceiveAndDelete risks loss and gives no ordering, and Event Grid provides neither dedupe windows nor per-key ordering.

The winning configuration is the one that turns on duplicate detection for a 10-minute window and uses sessions keyed by OrderId. Those two settings answer two different failure modes: the deduplication window prevents a second submission for an OrderId from entering the queue, and the session gives every message carrying that order key a single logical FIFO lane with one active consumer. A queue or subscription must be session-enabled, and the sender must put the order identifier into the broker's session field; otherwise the session setting is inert or the message is rejected.

The non-obvious mechanism is that Service Bus duplicate detection compares the broker-level MessageId, not an arbitrary OrderId application property. A producer that generates a fresh GUID for every send will evade the 10-minute window even when the business payload repeats OrderId 12345. To make that configuration work, the sender should use OrderId (or a deterministic value derived from it) as MessageId for the submission, so the second send within ten minutes is recognized as a duplicate and discarded. Duplicate history is maintained per messaging entity for the configured window, so the window must be enabled on the same queue or topic subscription that receives the orders.

Sessions add the ordering guarantee that duplicate detection alone cannot provide. With RequiresSession enabled and SessionId set to OrderId, Service Bus associates all messages for one order with the same session, delivers them in order, and prevents two competing receivers from processing that session concurrently. That is why the requirement is not merely 'no duplicates' but 'no duplicates plus per-order sequence': two distinct order updates with different MessageIds must still be serialized, and sessions are the Service Bus construct that supplies that serialization. The session lock also means a failed receiver can release the session and another can resume it without splitting one order's stream across consumers.

ReceiveAndDelete with prefetch fails on both counts. ReceiveAndDelete settles a message as soon as the broker hands it to the client, so a crash can lose an order, and prefetch merely fills a client-side buffer; neither setting enables the duplicate-detection window or creates an OrderId-based session. Partitioning and a large max size are capacity and throughput controls: they distribute load and raise the entity's storage ceiling, but they do not inspect repeated OrderIds or force all messages for one order through one ordered consumer. Event Grid with retries is an event-distribution mechanism, not an ordered queue with a deduplication window; retries are at-least-once and can re-deliver an event, so duplicate submissions remain possible, and Event Grid does not give per-OrderId ordering.

The correct choice therefore pairs the 10-minute duplicate-detection window with session-enabled, OrderId-keyed processing, provided the sends populate MessageId and SessionId consistently. That combination directly implements both guarantees, whereas the other options address delivery speed, capacity, or event fan-out without satisfying both constraints.

Official Reference

Exam Strategy

When a requirement pairs a deduplication window with per-entity ordering, map each clause to a separate Service Bus feature instead of looking for one setting that covers both: duplicate detection handles repeat suppression, and sessions handle sequencing. Check the actual broker properties—MessageId for deduplication and SessionId for session affinity—because an application-level OrderId only helps if the sender copies it into those fields. Eliminate answers that improve throughput (partitioning, max size) or retry delivery (Event Grid) but leave one of the two requirements unmet.

Practice All AI-200 Questions

Access 69 questions with complete answers and detailed explanations.

View Full AI-200 Practice Test →

← Back to AI-200 Study Guide