Skip to content
On this page

Using Amazon SQS

TIP

Wolverine is only supporting SQS queues for right now, but support for publishing or subscribing through Amazon SNS will come shortly.

Wolverine supports Amazon SQS as a messaging transport through the WolverineFx.AmazonSqs package.

Connecting to the Broker

First, if you are using the shared AWS config and credentials files, the SQS connection is just this:

cs
var host = await Host.CreateDefaultBuilder()
    .UseWolverine(opts =>
    {
        opts.UseAmazonSqsTransport()

            // Let Wolverine create missing queues as necessary
            .AutoProvision()

            // Optionally purge all queues on application startup. 
            // Warning though, this is potentially slow
            .AutoPurgeOnStartup();
    }).StartAsync();

snippet source | anchor

cs
var host = await Host.CreateDefaultBuilder()
    .UseWolverine((context, opts) =>
    {
        var config = context.Configuration;

        opts.UseAmazonSqsTransport(sqsConfig =>
            {
                sqsConfig.ServiceURL = config["AwsUrl"];
                // And any other elements of the SQS AmazonSQSConfig
                // that you may need to configure
            })

            // Let Wolverine create missing queues as necessary
            .AutoProvision()

            // Optionally purge all queues on application startup. 
            // Warning though, this is potentially slow
            .AutoPurgeOnStartup();
    }).StartAsync();

snippet source | anchor

If you'd just like to connect to Amazon SQS running from within LocalStack on your development box, there's this helper:

cs
var host = await Host.CreateDefaultBuilder()
    .UseWolverine(opts =>
    {
        // Connect to an SQS broker running locally
        // through LocalStack
        opts.UseAmazonSqsTransportLocally();
    }).StartAsync();

snippet source | anchor

Configuring Queues

Listening to Queues

Publishing to Queues

Conventional Message Routing

Released under the MIT License.