Amazon SQS Transport

NuGet Package NServiceBus.AmazonSQS (1.x)
Target NServiceBus Version: 5.x
Standard support for version 5.x of NServiceBus has expired. For more information see our Support Policy.

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

Transport at a glance

TransactionsNone, ReceiveOnly (Message visibility timeout)
Pub/SubMessage driven
TimeoutsNative (up to 15 minutes), TimeoutManager
Large message bodiesNative (Requires S3)
Scale-outCompeting consumer
Scripted DeploymentPowerShell, CloudFormation, C#


  • 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, such as IAM, CloudWatch, and Lambda. 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.
  • Can send and receive large messages that exceed the queue limitations by storing large payloads in S3. For more information review the documentation for the transport topology and configuration options.


  • 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.


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

The IAM account requires the following permissions:

SQS permissions

  • CreateQueue
  • DeleteMessage
  • DeleteMessageBatch
  • GetQueueUrl
  • ReceiveMessage
  • SendMessage
  • SendMessageBatch
  • SetQueueAttributes
  • GetQueueAttributes
  • 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 = busConfiguration.UseTransport<SqsTransport>();
// S3 bucket only required for messages larger than 256KB

For more configuration options, consult the configuration options page.

Retries and timeouts

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

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


Messages sent from within a handler are batched with up to ten messages per batch depending on the size of the message. Messages sent outside a handler are not batched.


Related Articles

Last modified