Rig.TUnit.Messaging.Sqs
0.1.0-beta.2
dotnet add package Rig.TUnit.Messaging.Sqs --version 0.1.0-beta.2
NuGet\Install-Package Rig.TUnit.Messaging.Sqs -Version 0.1.0-beta.2
<PackageReference Include="Rig.TUnit.Messaging.Sqs" Version="0.1.0-beta.2" />
<PackageVersion Include="Rig.TUnit.Messaging.Sqs" Version="0.1.0-beta.2" />
<PackageReference Include="Rig.TUnit.Messaging.Sqs" />
paket add Rig.TUnit.Messaging.Sqs --version 0.1.0-beta.2
#r "nuget: Rig.TUnit.Messaging.Sqs, 0.1.0-beta.2"
#:package Rig.TUnit.Messaging.Sqs@0.1.0-beta.2
#addin nuget:?package=Rig.TUnit.Messaging.Sqs&version=0.1.0-beta.2&prerelease
#tool nuget:?package=Rig.TUnit.Messaging.Sqs&version=0.1.0-beta.2&prerelease
Rig.TUnit.Messaging.Sqs
LocalStack-backed Amazon SQS fixture with FIFO + standard queue topology,
MessageGroupId-aware listener, andOrderingAssertfor per-group strict ordering.
What this package is
The Rig.TUnit Amazon SQS provider. SqsFixture spins the LocalStack
image with the SQS feature enabled and returns an IAmazonSQS pointing
at it. Ships async listener / sender helpers on AWSSDK.SQS. Ships:
SqsEventSender— sender with aSendContextoverload mappingSessionKey→MessageGroupId(mandatory on FIFO queues),DeduplicationKey→MessageDeduplicationId. ThrowsInvalidOperationExceptionon FIFO queues whenSessionKeyis missing — emulating the broker's precondition before round-trip.SqsListener— requestsMessageGroupId+SequenceNumberattributes on receive and populatesCapturedMessage.SessionKey.SqsTopologyBuilder+ provider-scoped interfaces (ISqsTopologyBuilder,ISqsQueueConfig) wired viaSqsRigBuilder.WithTopology(…).WithFifo(contentBasedDeduplication)appends the mandatory.fifosuffix and writesFifoQueue=true;WithDeadLetter(name, maxReceiveCount)provisions the redrive policy;WithVisibilityTimeout/WithMessageRetentionPeriodmap to the matching queue attributes.OrderingAssert— knows the FIFO-queue contract (per-MessageGroupIdstrict ordering, otherwise best-effort).
When to use it
- Integration tests for SQS consumers / producers.
- Asserting strict FIFO ordering by
MessageGroupId. - Provisioning FIFO queues + DLQs + redrive policies at runtime from test code.
- Content-based deduplication verification.
- Dead-letter queue and retry-policy verification.
- Not for: unit tests; mock the SQS client.
Prerequisites
- .NET 10 SDK
- Docker Desktop / Colima (LocalStack image ~400 MB)
AWSSDK.SQS(transitive)
Quick start
using Rig.TUnit.Messaging.Helpers;
using Rig.TUnit.Messaging.Sqs.Fixtures;
using Rig.TUnit.Messaging.Sqs.Helpers;
await using var fx = new SqsFixture();
await fx.InitializeAsync();
var queue = await fx.Client.CreateQueueAsync("orders");
await using var sender = new SqsEventSender(fx.Client, queue.QueueUrl);
await sender.SendAsync(
"{\"orderId\":1}",
context: new SendContext(SessionKey: "customer-42"),
ct: ct);
FIFO queue + DLQ via the WithTopology rig hook (the .fifo suffix is
appended automatically by WithFifo):
services.AddRigTUnit(rig =>
rig.UseSqs(RigConnect.FromValue(fx.Endpoint), s =>
s.WithTopology(t =>
t.Queue("orders-dlq")
.Queue("orders", c => c
.WithFifo(contentBasedDeduplication: true)
.WithDeadLetter("orders-dlq", maxReceiveCount: 5)
.WithVisibilityTimeout(TimeSpan.FromSeconds(30))))));
Options
| Property | Type | Default | Description |
|---|---|---|---|
Image |
string |
"localstack/localstack:3" |
LocalStack image |
StartupTimeoutSeconds |
int |
120 |
LocalStack boot |
Region |
string |
"us-east-1" |
Region label |
AccessKeyId |
string |
"test" |
LocalStack default |
SecretAccessKey |
string |
"test" |
LocalStack default |
Fixture + helper APIs
Rig.TUnit.Messaging.Sqs.Fixtures.SqsFixtureRig.TUnit.Messaging.Sqs.Options.SqsFixtureOptionsRig.TUnit.Messaging.Sqs.Builder.SqsRigBuilder— shipsWithTopology(Action<ISqsTopologyBuilder>).Rig.TUnit.Messaging.Sqs.Helpers.SqsListener— populatesCapturedMessage.SessionKeyfromMessageGroupId.Rig.TUnit.Messaging.Sqs.Helpers.SqsEventSender— shipsSendAsync(string, SendContext, …)overload.Rig.TUnit.Messaging.Sqs.Topology.ISqsTopologyBuilderRig.TUnit.Messaging.Sqs.Topology.ISqsQueueConfig—WithFifo,WithVisibilityTimeout,WithDeadLetter,WithMessageRetentionPeriod.Rig.TUnit.Messaging.Sqs.Topology.SqsTopologyBuilder
Per-test isolation
Per-test queue name: orders_{IsolationKey:short}.fifo or .std.
LocalStack supports queue create/delete at high concurrency, so
parallelism is effectively unbounded.
Parallelism + performance
- First-run pull: ~30 s.
- Warm startup: ~10 s.
- Per-op send: ~30–50 ms (LocalStack's SQS endpoint is slower than ephemeral-queue real AWS due to per-op HTTP overhead).
- Parallelism: 8+ concurrent tests.
Troubleshooting
- Long receive latency — SQS long-polling defaults to 20 s. Tests
asserting rapid delivery must set
WaitTimeSeconds=0on the receive request. - Message never arrives in FIFO queue — FIFO queues require
MessageGroupIdon send;SqsEventSendersets it from theIsolationKeyby default, overridable.
See docs/troubleshooting.md#sqs.
Provider quirks + edge cases
- FIFO queue names must end with
.fifo; standard queues must not.ISqsQueueConfig.WithFifo()appends the suffix automatically — do not pass"orders.fifo"toQueue("orders", c => c.WithFifo()). - FIFO queues require
MessageGroupIdon every send;SqsEventSender.SendAsync(SendContext)enforces this and throwsInvalidOperationExceptionbefore the broker round-trip whenSessionKeyis missing on a.fifoqueue. - Content-based deduplication requires
ContentBasedDeduplication=trueon queue creation — passWithFifo(contentBasedDeduplication: true). SendContext.PartitionKeyis meaningless on SQS (no partitioned primitive); the sender ignores it on standard and FIFO queues.- Topology apply is idempotent: re-running the same
WithTopologydeclaration succeeds viaCreateQueueAsyncreturning the existing queue URL when attributes match. - LocalStack's SQS diverges from real AWS on: delay-queue timing accuracy, cross-region replication, KMS-encrypted queues. Verify these against real AWS before prod.
Benchmarks
See SqsMessagingBenchmarks.cs;
baseline in benchmarks/baseline-005.json.
Related docs
- Architecture diagram
- Glossary
- Provider deep-dive:
docs/providers/sqs.md(FIFO ordering, DLQ redrive, content-based dedup, isolation key prefix guidance). - Family base:
Rig.TUnit.Messaging - Feature design: Sessions & Partitions · Topology Builder
License
MIT. See LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- AWSSDK.SQS (>= 3.7.400)
- Bogus (>= 35.6.1)
- Microsoft.Extensions.Configuration (>= 10.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.0)
- Microsoft.Extensions.Options (>= 10.0.0)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.0)
- Rig.TUnit.Messaging (>= 0.1.0-beta.2)
- Testcontainers (>= 4.11.0)
- Testcontainers.LocalStack (>= 4.11.0)
- TUnit.Core (>= 1.34.5)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Rig.TUnit.Messaging.Sqs:
| Package | Downloads |
|---|---|
|
Rig.TUnit.All
Meta-package containing every Rig.TUnit.* package. DISCOURAGED — prefer per-feature or per-stack meta-packages (Rig.TUnit, Rig.TUnit.Microservices). |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.1.0-beta.2 | 41 | 4/27/2026 |
| 0.0.0-alpha.0.14 | 47 | 4/26/2026 |