Table of Contents

Interface IAwsSqsSnsBuilder

Namespace
Excalibur.Dispatch.Transport.Aws
Assembly
Excalibur.Dispatch.Transport.AwsSqs.dll

Fluent builder interface for configuring AWS SNS topic integration with SQS transport.

public interface IAwsSqsSnsBuilder
Extension Methods

Examples

services.AddAwsSqsTransport("orders", sqs =>
{
    sqs.UseRegion("us-east-1")
       .ConfigureSns(sns =>
       {
              .RawMessageDelivery(true)
              .MapTopic<OrderCreated>("arn:aws:sns:us-east-1:123:orders")
              .SubscribeQueue<OrderCreated>(sub =>
              {
                  sub.TopicArn("arn:aws:sns:us-east-1:123:orders")
                     .QueueUrl("https://sqs.us-east-1.amazonaws.com/123/orders")
                     .FilterPolicy(filter =>
                     {
                         filter.OnMessageAttributes()
                               .Attribute("priority").Equals("high")
                               .Attribute("region").Prefix("us-");
                     });
              });
       });
});

Remarks

This interface follows the Microsoft-style fluent builder pattern. All methods return this for method chaining.

SNS integration enables pub/sub messaging patterns where messages published to SNS topics are delivered to subscribed SQS queues with optional filter policies.

Methods

MapTopic<TMessage>(string)

Maps a message type to a specific SNS topic ARN.

IAwsSqsSnsBuilder MapTopic<TMessage>(string topicArn) where TMessage : class

Parameters

topicArn string

The full SNS topic ARN.

Returns

IAwsSqsSnsBuilder

The builder for fluent chaining.

Type Parameters

TMessage

The message type to map.

Examples

sns.MapTopic<OrderCreated>("arn:aws:sns:us-east-1:123456789012:orders")
   .MapTopic<PaymentReceived>("arn:aws:sns:us-east-1:123456789012:payments");

Remarks

When a mapping exists for a message type, the transport will publish that message to the specified SNS topic instead of directly to an SQS queue.

Exceptions

ArgumentException

Thrown when topicArn is null, empty, or whitespace.

RawMessageDelivery(bool)

Enables or disables raw message delivery for all subscriptions.

IAwsSqsSnsBuilder RawMessageDelivery(bool enable = true)

Parameters

enable bool

true to deliver raw messages without SNS envelope; false to include the SNS envelope. Default is false.

Returns

IAwsSqsSnsBuilder

The builder for fluent chaining.

Examples

sns.RawMessageDelivery(true);

Remarks

When raw message delivery is enabled, messages are delivered directly to SQS without the SNS notification envelope. This reduces message size overhead but removes access to SNS message attributes in the SQS message.

Individual subscriptions can override this setting.

SubscribeQueue<TMessage>(Action<IAwsSqsSubscriptionBuilder>)

Configures an SNS-to-SQS subscription for a message type.

IAwsSqsSnsBuilder SubscribeQueue<TMessage>(Action<IAwsSqsSubscriptionBuilder> configure) where TMessage : class

Parameters

configure Action<IAwsSqsSubscriptionBuilder>

The subscription configuration action.

Returns

IAwsSqsSnsBuilder

The builder for fluent chaining.

Type Parameters

TMessage

The message type for this subscription.

Examples

sns.SubscribeQueue<OrderCreated>(sub =>
{
    sub.TopicArn("arn:aws:sns:us-east-1:123:orders")
       .QueueUrl("https://sqs.us-east-1.amazonaws.com/123/orders")
       .FilterPolicy(filter =>
       {
           filter.Attribute("priority").Equals("high");
       });
});

Remarks

Subscriptions define how messages from an SNS topic are delivered to an SQS queue. Use the IAwsSqsSubscriptionBuilder to configure the topic ARN, queue URL, raw message delivery, and filter policies.

Exceptions

ArgumentNullException

Thrown when configure is null.