Skip to content
On this page

Amazon SQS

PM> Install-Package Shuttle.Esb.AmazonSqs

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.

Configuration

The URI structure is amazonsqs://configuration-name/queue-name.

c#
services.AddAmazonSqs(builder =>
{
    var amazonSqsOptions = new AmazonSqsOptions
    {
        ServiceUrl = "http://localhost:9324",
        MaxMessages = 1,
        WaitTime = TimeSpan.FromSeconds(20)
    };

    amazonSqsOptions.Configure += (sender, args) =>
    {
        Console.WriteLine($"[event] : Configure / Uri = '{((IQueue)sender).Uri}'");
    };

    builder.AddOptions("local", amazonSqsOptions);
});

The Configure event args arugment exposes the AmazonSQSConfig directly for any specific options that need to be set.

The default JSON settings structure is as follows:

json
{
  "Shuttle": {
    "AmazonSqs": {
      "local": {
        "ServiceUrl": "http://localhost:9324",
        "MaxMessages": 5,
        "WaitTime": "00:00:20"
      },
      "proper": {
        "ServiceUrl": "https://sqs.us-east-2.amazonaws.com/123456789012/MyQueue"
      }
    }
  }
}

Options

OptionDefaultDescription
ServiceUrlThe URL to connect to.
MaxMessages10Specifies the number of messages to fetch from the queue.
WaitTime00:00:20Specifies the TimeSpan duration to perform long-polling.
Amazon SQS has loaded