Amazon SQS Transport

Project Hosting
NuGet Package NServiceBus.AmazonSQS (3.x)
Target NServiceBus Version: 6.x

Simple Queue Service (SQS) is a message queue service provided by Amazon Web Services.

Advantages

  • Fully managed turn-key messaging infrastructure. SQS queues requires very little effort to set up, maintain and manage over time.
  • Integrates seamlessly with other services provided by AWS, for example, IAM, CloudWatch, Lambda, etc. For organizations already committed to AWS, SQS is a natural choice.
  • Can be used as a gateway between endpoints that may not have direct connectivity to each-other.

Disadvantages

  • Like other message brokers, there is no local store-and-forward mechanism available. If an endpoint cannot reach SQS, either due to network problems or if SQS is unavailable, the endpoint will not be able to send nor receive messages.
  • Can be relatively expensive when using larger volumes of messages.

Getting Started

An AWS IAM account with a pair of Access Keys is required.

The IAM account requires the following:

SQS permissions

  • CreateQueue
  • DeleteMessage
  • DeleteMessageBatch
  • GetQueueUrl
  • ReceiveMessage
  • SendMessage
  • SendMessageBatch
  • SetQueueAttributes
  • ChangeMessageVisibility
  • ChangeMessageVisibilityBatch
  • PurgeQueue

S3 permissions

  • CreateBucket
  • DeleteObject
  • GetObject
  • PutObject
  • PutLifecycleConfiguration
  • GetLifecycleConfiguration
  • ListAllMyBuckets

By default, AWS Access Key ID and AWS Secret Access Key are discovered from environment variables of the machine that is running the endpoint:

  • Access Key ID goes in AWS_ACCESS_KEY_ID
  • Secret Access Key goes in AWS_SECRET_ACCESS_KEY
var transport = endpointConfiguration.UseTransport<SqsTransport>();
transport.Region("ap-southeast-2");
transport.S3BucketForLargeMessages("myBucketName", "my/key/prefix");

Retries and Timeouts

The SQS transport uses the default retries and timeouts values implemented by the AWS SDK for .NET:

ParameterDefault value
MaxErrorRetries4
RequestTimeout100s
ReadWriteTimeout300s
NServiceBus will perform immediate and delayed retries in addition to retries performed internally by the SQS client.

Samples

Related Articles

  • Configuration Options
    Configuration options for the SQS transport.
  • Scripting
    Example code and scripts to facilitate deployment and operational actions against the SQS Transport.
  • Topology
    Identify the physical components used by the transport and how they interact.
  • Transaction Support
    Explore the transaction modes the transport supports.
  • Why Use SQS?
    Explore when it makes sense to use SQS as a transport.

Last modified