Amazon Simple Queue Service (SQS) implementation for use with Shuttle.Hopper, providing reliable message queuing capabilities using AWS SQS.
In order to make use of the AmazonSqsQueue you will need access to an Amazon Web Services account. There are some options for local development, such as ElasticMQ, which are beyond the scope of this documentation.
You may also want to take a look at Messaging Using Amazon SQS.
dotnet add package Shuttle.Hopper.AmazonSqsThe URI structure is amazonsqs://configuration-name/queue-name.
services.AddHopper(hopperBuilder =>
{
hopperBuilder.UseAmazonSqs(builder =>
{
var amazonSqsOptions = new AmazonSqsOptions
{
AwsCredentials = new BasicAWSCredentials("accessKey", "secretKey"),
AmazonSqsConfig = new AmazonSQSConfig
{
ServiceURL = "http://localhost:9324",
AuthenticationRegion = "us-east-1"
},
MaxMessages = 5,
WaitTime = TimeSpan.FromSeconds(20)
};
builder.AddOptions("local", amazonSqsOptions);
});
});The default JSON settings structure is as follows:
{
"Shuttle": {
"AmazonSqs": {
"local": {
"MaxMessages": 5,
"WaitTime": "00:00:20",
"AmazonSqsConfig": {
"ServiceURL": "http://localhost:9324"
}
},
"production": {
"MaxMessages": 10,
"WaitTime": "00:00:20",
"AmazonSqsConfig": {
"ServiceURL": "https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue"
}
}
}
}
}Important
Complex types like AwsCredentials and detailed AmazonSqsConfig properties must be configured programmatically. JSON configuration supports only simple properties like MaxMessages and WaitTime, plus the ServiceURL within AmazonSqsConfig.
amazonsqs://local/my-queue
amazonsqs://production/order-processing-queue
The configuration name (e.g., local, production) must match a configuration defined via AddOptions().
| Option | Default | Description |
|---|---|---|
AwsCredentials |
null |
AWS credentials for authentication. If null, the AWS SDK will use the default credential provider chain (environment variables, IAM roles, etc.). |
AmazonSqsConfig |
null |
AWS SQS configuration object. If null, a default configuration will be created. Use this to set ServiceURL, AuthenticationRegion, and other AWS-specific settings. |
MaxMessages |
10 |
Specifies the number of messages to fetch from the queue in a single request. Valid range: 1-10 (values outside this range will be automatically clamped). |
WaitTime |
00:00:20 |
Specifies the TimeSpan duration to perform long-polling. Valid range: 00:00:00 to 00:00:20 (values outside this range will be automatically clamped). |
Note
The MaxMessages value is automatically clamped between 1 and 10, as per AWS SQS API limits. The WaitTime is clamped between 0 and 20 seconds.
AWS credentials can be configured in several ways:
amazonSqsOptions.AwsCredentials = new BasicAWSCredentials("accessKey", "secretKey");If AwsCredentials is not set, the AWS SDK will automatically use credentials from:
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEYenvironment variables- AWS credentials file (
~/.aws/credentials) - IAM role (when running on EC2 or ECS)
When running on AWS infrastructure, use IAM roles instead of hardcoded credentials.
If you see errors about unresolved queue URLs, ensure:
- The queue exists in your AWS account
- The configuration name in the URI matches your configured options
- Your AWS credentials have permission to access the queue
If you encounter authentication errors:
- Verify your AWS credentials are correct
- Check that the
AuthenticationRegionmatches your queue's region - Ensure your IAM user/role has the necessary SQS permissions
The configuration name in the URI (e.g., amazonsqs://local/queue-name) must exactly match a configuration added via builder.AddOptions("local", ...). Configuration names are case-sensitive.