Excalibur.Dispatch.Transport.AwsSqs
3.0.0-alpha.216
dotnet add package Excalibur.Dispatch.Transport.AwsSqs --version 3.0.0-alpha.216
NuGet\Install-Package Excalibur.Dispatch.Transport.AwsSqs -Version 3.0.0-alpha.216
<PackageReference Include="Excalibur.Dispatch.Transport.AwsSqs" Version="3.0.0-alpha.216" />
<PackageVersion Include="Excalibur.Dispatch.Transport.AwsSqs" Version="3.0.0-alpha.216" />Directory.Packages.props
<PackageReference Include="Excalibur.Dispatch.Transport.AwsSqs" />Project file
paket add Excalibur.Dispatch.Transport.AwsSqs --version 3.0.0-alpha.216
#r "nuget: Excalibur.Dispatch.Transport.AwsSqs, 3.0.0-alpha.216"
#:package Excalibur.Dispatch.Transport.AwsSqs@3.0.0-alpha.216
#addin nuget:?package=Excalibur.Dispatch.Transport.AwsSqs&version=3.0.0-alpha.216&prereleaseInstall as a Cake Addin
#tool nuget:?package=Excalibur.Dispatch.Transport.AwsSqs&version=3.0.0-alpha.216&prereleaseInstall as a Cake Tool
Excalibur.Dispatch.Transport.AwsSqs
AWS messaging transport implementation for the Excalibur framework, providing integration with Amazon SQS, SNS, and EventBridge services.
Part Of
This package is included in the following metapackages:
| Metapackage | Tier | What It Adds |
|---|---|---|
Excalibur.Dispatch.Aws |
Starter | + Resilience (Polly) + Observability |
Tip: If you are getting started, install
Excalibur.Dispatch.Awsinstead of this package directly. It includes production-ready defaults.
Overview
This package provides AWS messaging integration for Excalibur.Dispatch, enabling:
- Amazon SQS: Standard and FIFO queues with long polling and batching
- Amazon SNS: Pub/sub messaging with topic subscriptions
- Amazon EventBridge: Event-driven architectures with event buses and rules
- CloudEvents Support: Standards-compliant event formatting
- KMS Encryption: Server-side encryption with AWS Key Management Service
- LocalStack Support: Local development and testing without AWS account
Installation
dotnet add package Excalibur.Dispatch.Transport.AwsSqs
Configuration
Connection Options
Using Default Credentials
AWS SDK automatically discovers credentials from environment, IAM roles, or credential files:
services.AddAwsSqs(options =>
{
options.QueueUrl = new Uri("https://sqs.us-east-1.amazonaws.com/123456789/my-queue");
options.Region = "us-east-1";
});
Using Explicit Credentials
services.AddAwsSqs(options =>
{
options.QueueUrl = new Uri("https://sqs.us-east-1.amazonaws.com/123456789/my-queue");
options.Region = "us-east-1";
options.Credentials = new BasicAWSCredentials("accessKey", "secretKey");
});
Environment Variables
Configure via environment variables for containerized deployments:
AWS_ACCESS_KEY_ID=your-access-key
AWS_SECRET_ACCESS_KEY=your-secret-key
AWS_REGION=us-east-1
SQS_QUEUE_URL=https://sqs.us-east-1.amazonaws.com/123456789/my-queue
services.AddAwsSqs(options =>
{
options.QueueUrl = new Uri(Environment.GetEnvironmentVariable("SQS_QUEUE_URL")!);
options.Region = Environment.GetEnvironmentVariable("AWS_REGION") ?? "us-east-1";
});
LocalStack for Development
Use LocalStack for local development without AWS credentials:
services.AddAwsSqs(options =>
{
options.UseLocalStack = true;
options.LocalStackUrl = new Uri("http://localhost:4566");
options.QueueUrl = new Uri("http://localhost:4566/000000000000/my-queue");
});
Authentication
IAM Roles (Recommended for Production)
For EC2, ECS, Lambda, or EKS deployments, use IAM roles:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sqs:SendMessage",
"sqs:ReceiveMessage",
"sqs:DeleteMessage",
"sqs:GetQueueAttributes",
"sqs:ChangeMessageVisibility"
],
"Resource": "arn:aws:sqs:us-east-1:123456789:my-queue"
}
]
}
Assume Role
services.AddAwsSqs(options =>
{
options.Credentials = new AssumeRoleAWSCredentials(
new BasicAWSCredentials("accessKey", "secretKey"),
"arn:aws:iam::123456789:role/my-role",
"session-name");
options.Region = "us-east-1";
});
AWS SSO / Identity Center
Use AWS CLI profiles with SSO:
services.AddAwsSqs(options =>
{
options.Credentials = new ProfileAWSCredentials("my-sso-profile");
options.Region = "us-east-1";
});
Message Configuration
Standard Queue Settings
services.AddAwsSqs(options =>
{
options.QueueUrl = new Uri("https://sqs.us-east-1.amazonaws.com/123456789/my-queue");
// Polling configuration
options.MaxNumberOfMessages = 10; // Max messages per receive (1-10)
options.WaitTimeSeconds = TimeSpan.FromSeconds(20); // Long polling wait time (0-20 seconds)
options.VisibilityTimeout = TimeSpan.FromSeconds(30); // Message lock timeout
// Message retention
options.MessageRetentionPeriod = 345600; // 4 days (in seconds)
});
FIFO Queue Settings
services.AddAwsSqs(options =>
{
options.QueueUrl = new Uri("https://sqs.us-east-1.amazonaws.com/123456789/my-queue.fifo");
// FIFO-specific options
options.UseFifoQueue = true;
options.ContentBasedDeduplication = true; // Auto-generate deduplication ID from content
});
Batch Configuration
services.AddAwsSqs(options =>
{
options.BatchConfig = new BatchOptions
{
MaxBatchSize = 10, // Messages per batch (max 10)
MaxBatchWaitTime = TimeSpan.FromMilliseconds(100)
};
});
Long Polling Configuration
services.AddAwsSqs(options =>
{
options.LongPollingConfig = new LongPollingOptions
{
QueueUrl = new Uri("https://sqs.us-east-1.amazonaws.com/123456789/my-queue"),
};
options.LongPollingConfig.Polling.MaxWaitTimeSeconds = 20;
options.LongPollingConfig.Adaptive.Enabled = true;
});
Payload Compression
Compress large payloads when publishing to stay within the 256 KB SQS limit:
var publishOptions = new PublishOptions
{
Compression = CompressionAlgorithm.Gzip,
CompressionThresholdBytes = 10 * 1024, // 10 KB
};
var publisher = serviceProvider.GetRequiredService<ICloudMessagePublisher>();
await publisher.PublishAsync(new CloudMessage
{
Body = Encoding.UTF8.GetBytes("payload"),
}, CancellationToken.None);
Compressed messages include dispatch-compression and dispatch-body-encoding=base64 attributes; the SQS consumer automatically decodes them.
Supported compression algorithms for SQS payloads are Gzip, Deflate, and Brotli. Snappy is not supported.
Retry Policies
Retry Configuration
services.AddAwsSqs(options =>
{
options.MaxRetries = 3; // AWS SDK retry count
options.RequestTimeout = TimeSpan.FromSeconds(30); // Request timeout
options.ValidateOnStartup = true; // Validate queue exists on startup
});
Dead Letter Queue Configuration
services.Configure<DlqOptions>(options =>
{
options.DeadLetterQueueUrl = new Uri("https://sqs.us-east-1.amazonaws.com/123456789/my-dlq");
options.MaxRetries = 3; // Max retries before DLQ
options.RetryDelay = TimeSpan.FromMinutes(5); // Delay between retries
options.UseExponentialBackoff = true; // Exponential backoff
options.MaxMessageAge = TimeSpan.FromDays(14); // Max message age to process
// Archive options
options.ArchiveFailedMessages = true;
options.ArchiveLocation = "s3://my-bucket/dlq-archive/";
// Automatic redrive
options.EnableAutomaticRedrive = true;
options.AutomaticRedriveInterval = TimeSpan.FromHours(1);
});
Encryption
KMS Server-Side Encryption
services.AddAwsSqs(options =>
{
options.EnableEncryption = true;
options.KmsMasterKeyId = "alias/my-key"; // KMS key alias or ARN
options.KmsDataKeyReusePeriodSeconds = 300; // Data key reuse period (60-86400)
});
Required IAM Permissions for KMS
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"kms:GenerateDataKey",
"kms:Decrypt"
],
"Resource": "arn:aws:kms:us-east-1:123456789:key/my-key-id"
}
]
}
Health Checks
Registration
services.AddHealthChecks()
.AddCheck<SqsHealthCheck>("sqs", tags: new[] { "ready", "messaging" });
Configuration
services.Configure<SqsHealthCheckOptions>(options =>
{
options.Timeout = TimeSpan.FromSeconds(5);
options.QueueUrl = "https://sqs.us-east-1.amazonaws.com/123456789/my-queue";
});
Custom Health Check Implementation
public class SqsHealthCheck : IHealthCheck
{
private readonly IAmazonSQS _sqsClient;
private readonly AwsSqsOptions _options;
public async Task<HealthCheckResult> CheckHealthAsync(
HealthCheckContext context,
CancellationToken cancellationToken = default)
{
try
{
var response = await _sqsClient.GetQueueAttributesAsync(
_options.QueueUrl?.ToString(),
new List<string> { "ApproximateNumberOfMessages" },
cancellationToken);
var messageCount = int.Parse(
response.Attributes["ApproximateNumberOfMessages"]);
return messageCount > 10000
? HealthCheckResult.Degraded($"Queue depth: {messageCount}")
: HealthCheckResult.Healthy($"Queue depth: {messageCount}");
}
catch (Exception ex)
{
return HealthCheckResult.Unhealthy("SQS unreachable", ex);
}
}
}
Production Considerations
Scaling
Horizontal Scaling
- Use multiple consumers reading from the same queue
- Adjust
VisibilityTimeoutbased on message processing time - Use Lambda with SQS triggers for automatic scaling
FIFO Queue Considerations
- FIFO queues have 300 TPS limit per message group
- Use multiple message groups for higher throughput
- Consider standard queues if ordering is not critical
Performance Tuning
services.AddAwsSqs(options =>
{
// High-throughput configuration
options.MaxNumberOfMessages = 10; // Max batch size
options.WaitTimeSeconds = TimeSpan.FromSeconds(20); // Long polling (reduces API calls)
options.VisibilityTimeout = TimeSpan.FromMinutes(5); // 5 minutes for slow processing
options.BatchConfig = new BatchOptions
{
MaxBatchSize = 10,
MaxBatchWaitTime = TimeSpan.FromMilliseconds(50) // Faster batching
};
});
Monitoring and Alerting
Key CloudWatch metrics to monitor:
| Metric | Description | Alert Threshold |
|---|---|---|
ApproximateNumberOfMessagesVisible |
Messages waiting | > 10,000 |
ApproximateNumberOfMessagesNotVisible |
In-flight messages | > VisibilityTimeout |
ApproximateAgeOfOldestMessage |
Message age | > retention period / 2 |
NumberOfMessagesSent |
Send rate | Baseline deviation |
NumberOfMessagesDeleted |
Process rate | < send rate (backlog growing) |
Cost Optimization
- Use long polling (
WaitTimeSeconds = TimeSpan.FromSeconds(20)) to reduce API calls - Batch operations for sends and deletes
- Use FIFO queues only when needed (higher cost)
- Set appropriate retention periods to avoid storage costs
Security Best Practices
- Use IAM roles instead of access keys in production
- Enable KMS encryption for sensitive data
- Use VPC endpoints to keep traffic within AWS
- Apply least-privilege permissions per queue
- Enable CloudTrail for audit logging
SNS Integration
Configuration
services.AddAwsSns(options =>
{
options.TopicArn = "arn:aws:sns:us-east-1:123456789:my-topic";
options.Region = "us-east-1";
});
Fanout Pattern (SNS to Multiple SQS)
// Publisher uses SNS
services.AddAwsSns(options =>
{
options.TopicArn = "arn:aws:sns:us-east-1:123456789:orders-topic";
});
// Multiple consumers subscribe SQS queues to the topic
// Configure in AWS Console or via CloudFormation
EventBridge Integration
Configuration
services.AddAwsEventBridge(options =>
{
options.EventBusName = "my-event-bus";
options.Region = "us-east-1";
options.DefaultSource = "my-application";
options.DefaultDetailType = "dispatch.event";
options.EnableArchiving = true;
options.ArchiveName = "my-event-archive";
options.ArchiveRetentionDays = 7;
});
Troubleshooting
Common Issues
Access Denied
Amazon.SQS.AmazonSQSException: Access to the resource is denied.
Solutions:
- Verify IAM permissions include required SQS actions
- Check queue policy allows your principal
- Ensure KMS permissions if encryption is enabled
- Verify the correct AWS account/region
Queue Does Not Exist
Amazon.SQS.AmazonSQSException: The specified queue does not exist.
Solutions:
- Verify queue URL is correct
- Check queue exists in the correct region
- Ensure queue name matches (case-sensitive)
- For FIFO queues, include
.fifosuffix
Message Not Deleted
Messages keep reappearing after processing.
Solutions:
- Ensure message is explicitly deleted after processing
- Increase
VisibilityTimeoutif processing takes longer - Check for exceptions preventing deletion
- Verify delete permissions in IAM policy
Visibility Timeout Too Short
Amazon.SQS.AmazonSQSException: Message has expired
Solutions:
- Increase
VisibilityTimeoutto exceed processing time - Use
ChangeMessageVisibilityfor long-running tasks - Consider breaking large tasks into smaller messages
Logging Configuration
Enable detailed logging for troubleshooting:
{
"Logging": {
"LogLevel": {
"Excalibur.Dispatch.Transport.AwsSqs": "Debug",
"Amazon": "Warning",
"Amazon.SQS": "Information"
}
}
}
Debug Tips
Enable AWS SDK logging:
AWSConfigs.LoggingConfig.LogTo = LoggingOptions.Console; AWSConfigs.LoggingConfig.LogResponses = ResponseLoggingOption.OnError;Use AWS CLI to test:
aws sqs receive-message --queue-url https://sqs.us-east-1.amazonaws.com/123456789/my-queueCheck CloudWatch Logs for Lambda-based consumers
Use X-Ray for distributed tracing
LocalStack logs for local development issues
Complete Configuration Reference
services.AddAwsSqs(options =>
{
// Connection
options.QueueUrl = new Uri("https://sqs.us-east-1.amazonaws.com/123456789/my-queue");
options.Region = "us-east-1";
options.ServiceUrl = null; // Custom endpoint (LocalStack, etc.)
options.UseLocalStack = false;
options.LocalStackUrl = new Uri("http://localhost:4566");
// Authentication
options.Credentials = null; // Uses default credential chain
// Queue type
options.UseFifoQueue = false;
options.ContentBasedDeduplication = false;
// Polling
options.MaxNumberOfMessages = 10;
options.WaitTimeSeconds = TimeSpan.FromSeconds(20);
options.VisibilityTimeout = TimeSpan.FromSeconds(30);
// Message settings
options.MessageRetentionPeriod = 345600; // 4 days
// Reliability
options.MaxRetries = 3;
options.RequestTimeout = TimeSpan.FromSeconds(30);
options.ValidateOnStartup = true;
options.EnableDeduplication = false;
// Encryption
options.EnableEncryption = false;
options.KmsMasterKeyId = null;
options.KmsDataKeyReusePeriodSeconds = 300;
});
// Dead Letter Queue
services.Configure<DlqOptions>(options =>
{
options.DeadLetterQueueUrl = new Uri("https://sqs.us-east-1.amazonaws.com/123456789/my-dlq");
options.MaxRetries = 3;
options.RetryDelay = TimeSpan.FromMinutes(5);
options.UseExponentialBackoff = true;
options.MaxMessageAge = TimeSpan.FromDays(14);
options.ArchiveFailedMessages = true;
options.ArchiveLocation = "s3://bucket/archive/";
options.BatchSize = 10;
options.EnableAutomaticRedrive = false;
options.AutomaticRedriveInterval = TimeSpan.FromHours(1);
});
See Also
| 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.CloudWatch (>= 4.0.9.4)
- AWSSDK.Core (>= 4.0.3.30)
- AWSSDK.DynamoDBv2 (>= 4.0.17.9)
- AWSSDK.EventBridge (>= 4.0.5.26)
- AWSSDK.S3 (>= 4.0.21.2)
- AWSSDK.Scheduler (>= 4.0.2.24)
- AWSSDK.SimpleNotificationService (>= 4.0.2.27)
- AWSSDK.SQS (>= 4.0.2.25)
- CloudNative.CloudEvents (>= 2.8.0)
- CloudNative.CloudEvents.SystemTextJson (>= 2.8.0)
- Cronos (>= 0.12.0)
- Excalibur.Dispatch (>= 3.0.0-alpha.216)
- Excalibur.Dispatch.Abstractions (>= 3.0.0-alpha.216)
- Excalibur.Dispatch.Resilience.Polly (>= 3.0.0-alpha.216)
- Excalibur.Dispatch.Transport.Abstractions (>= 3.0.0-alpha.216)
- Medo.Uuid7 (>= 3.2.0)
- Microsoft.AspNetCore.Authorization (>= 10.0.7)
- Microsoft.Extensions.Caching.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Caching.Memory (>= 10.0.7)
- Microsoft.Extensions.Configuration (>= 10.0.7)
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Configuration.Binder (>= 10.0.7)
- Microsoft.Extensions.DependencyInjection (>= 10.0.7)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.7)
- Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.7)
- Microsoft.Extensions.Http (>= 10.0.7)
- Microsoft.Extensions.Logging (>= 10.0.7)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.7)
- Microsoft.Extensions.ObjectPool (>= 10.0.7)
- Microsoft.Extensions.Options (>= 10.0.7)
- Microsoft.Extensions.Options.ConfigurationExtensions (>= 10.0.7)
- Microsoft.Extensions.Options.DataAnnotations (>= 10.0.7)
- Polly (>= 8.6.6)
- Polly.RateLimiting (>= 8.6.6)
- StackExchange.Redis (>= 2.12.14)
- System.IO.Hashing (>= 10.0.7)
- System.Threading.RateLimiting (>= 10.0.7)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Excalibur.Dispatch.Transport.AwsSqs:
| Package | Downloads |
|---|---|
|
Excalibur.Dispatch.Aws
Experience metapackage bundling Excalibur.Dispatch with AWS SQS transport. Provides a single AddDispatchAws() call for the common AWS messaging scenario. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 3.0.0-alpha.216 | 43 | 6/30/2026 |
| 3.0.0-alpha.215 | 60 | 6/23/2026 |
| 3.0.0-alpha.214 | 61 | 6/23/2026 |
| 3.0.0-alpha.208 | 60 | 6/11/2026 |
| 3.0.0-alpha.207 | 54 | 6/11/2026 |
| 3.0.0-alpha.205 | 57 | 6/10/2026 |
| 3.0.0-alpha.204 | 66 | 6/8/2026 |
| 3.0.0-alpha.203 | 65 | 6/8/2026 |
| 3.0.0-alpha.202 | 64 | 6/8/2026 |
| 3.0.0-alpha.201 | 57 | 6/8/2026 |
| 3.0.0-alpha.199 | 56 | 6/8/2026 |
| 3.0.0-alpha.198 | 65 | 5/28/2026 |
| 3.0.0-alpha.197 | 68 | 5/28/2026 |
| 3.0.0-alpha.194 | 62 | 5/20/2026 |
| 3.0.0-alpha.193 | 70 | 5/13/2026 |
| 3.0.0-alpha.192 | 54 | 5/13/2026 |
| 3.0.0-alpha.191 | 57 | 5/13/2026 |
| 3.0.0-alpha.189 | 63 | 5/12/2026 |
| 3.0.0-alpha.187 | 62 | 5/8/2026 |
| 3.0.0-alpha.185 | 65 | 5/7/2026 |