Skip to content

Support MessageGroupId on standard SQS queues for fair queues (GH-2886)#2889

Merged
jeremydmiller merged 1 commit into
mainfrom
feat-2886-sqs-fair-queue-groups
May 24, 2026
Merged

Support MessageGroupId on standard SQS queues for fair queues (GH-2886)#2889
jeremydmiller merged 1 commit into
mainfrom
feat-2886-sqs-fair-queue-groups

Conversation

@jeremydmiller
Copy link
Copy Markdown
Member

Problem

Closes #2886.

AWS SQS standard queues now support fair queues: setting MessageGroupId on a standard queue improves fairness for multi-tenant workloads so one tenant's backlog doesn't increase dwell time for others.

Wolverine already maps Envelope.GroupId → SQS MessageGroupId, but the mapping was gated behind IsFifoQueue (queue names ending in .fifo), so standard queues never received a MessageGroupId even when the envelope had a group id. That made it hard to use SQS fair queues through Wolverine without custom transport code.

Solution

Per the issue's recommended option, an opt-in, per-endpoint EnableFairQueueMessageGroups(), implemented at the envelope-mapping layer (per maintainer steer):

  • ISqsEnvelopeMapper.DetermineGroupId(Envelope) — a new default interface method returning Envelope.GroupId. Non-breaking for all existing mappers (NServiceBus, MassTransit, CloudEvents, RawJson, SNS); custom mappers can override to source the group id from a header, tenant id, etc.
  • AmazonSqsSubscriberConfiguration.EnableFairQueueMessageGroups() sets a per-endpoint flag on AmazonSqsQueue. Default off, so existing standard-queue users who set GroupId (e.g. via MessagePartitioning) are unaffected unless they opt in.
  • Both send paths (AmazonSqsQueue.SendMessageAsync and OutgoingSqsBatch) consult the mapper and gate on FIFO vs the flag:
    • FIFO — unchanged: always maps MessageGroupId + MessageDeduplicationId.
    • Standard + opt-in — maps MessageGroupId only; no deduplication semantics.

Usage:

opts.PublishMessage<OrderPlaced>()
    .ToSqsQueue("orders")
    .EnableFairQueueMessageGroups();

await bus.PublishAsync(message, new DeliveryOptions { GroupId = tenantId });

Tests

sqs_fair_queue_message_groups (no AWS dependency — exercises the real send mapping via OutgoingSqsBatch.Request): standard queue with the flag off leaves MessageGroupId unset; with it on maps the group id; never sets a deduplication id on a standard queue; FIFO still maps both regardless of the flag; and the fluent config flips the flag. 7/7 passing locally.

Docs

New Fair Queues page under the SQS guide + sidebar entry.

Notes

  • AWSSDK.SQS is already at 4.0.2.14; MessageGroupId exists on the request/batch-entry types, so no SDK bump.
  • SQS-only; no SNS changes.

🤖 Generated with Claude Code

AWS SQS standard queues now support "fair queues" by setting MessageGroupId
on messages, mitigating noisy-neighbor dwell time in multi-tenant workloads.
Wolverine already maps Envelope.GroupId -> SQS MessageGroupId, but only for
FIFO queues (names ending in .fifo); standard queues never received it.

Add an opt-in, per-endpoint EnableFairQueueMessageGroups() that maps
Envelope.GroupId -> MessageGroupId on standard queues too, with no ordering
or deduplication semantics (MessageDeduplicationId stays FIFO-only). The
group id is derived through the envelope-mapping layer via the new
ISqsEnvelopeMapper.DetermineGroupId(Envelope) (a default interface method
returning Envelope.GroupId, so existing custom mappers are unaffected and
can override to source the group id from a header/tenant id).

Both send paths (AmazonSqsQueue.SendMessageAsync and OutgoingSqsBatch) now
consult the mapper and gate on FIFO vs the opt-in flag. FIFO behavior is
unchanged. Adds unit tests and a Fair Queues docs page.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jeremydmiller jeremydmiller merged commit 9c72f8c into main May 24, 2026
22 of 24 checks passed
This was referenced May 28, 2026
This was referenced Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support MessageGroupId on standard SQS queues for fair queues

1 participant