Enable duplicate detection at queue or topic creation time (cannot be toggled post-creation): set RequiresDuplicateDetection=true and DuplicateDetectionHistoryTimeWindow; the default window is 10 minutes, minimum 20 seconds, maximum 7 days
Send messages with a MessageId set to a stable, business-meaningful identifier (e.g., order GUID); Service Bus rejects re-sent messages with the same MessageId within the detection window
Set an appropriate prefetch count on the receiver: ServiceBusReceiver with prefetchCount controls how many messages are fetched into the local client buffer ahead of explicit receive calls
Keep prefetchCount low (or 0) for session-enabled queues: a high prefetch count can pull messages from multiple sessions into one receiver's buffer, causing session starvation for other receivers
For non-session queues, set prefetchCount to a small multiple of your concurrent processing degree; too high a value results in messages sitting in the buffer past their lock expiration, requiring expensive lock renewal
Monitor MessageDeadLetterCount and ScheduledMessageCount in Azure Monitor to identify lock expiry dead-letters caused by overly aggressive prefetch
Known gotchas
Duplicate detection window setting cannot be changed after entity creation — plan the window duration carefully; a window too short will miss duplicates during slow processing or network partitions
Prefetch with sessions: the receiver holds an exclusive lock on a session; if prefetched messages from multiple sessions are buffered in one receiver, the other sessions are blocked until that receiver drains its buffer or disconnects
Duplicate detection is not available on partitioned entities in combination with sessions; check compatibility constraints before designing the entity layout
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp