API reference — Transports

Nuvora.Nexus.Relay.Messaging.AmazonSqs

Amazon SQS/SNS message transport for Nuvora Nexus Relay

dotnet add package Nuvora.Nexus.Relay.Messaging.AmazonSqs

Nuvora.Nexus.Relay.Messaging.AmazonSqs

AmazonSqsDeadLetterReplayer

public sealed class AmazonSqsDeadLetterReplayer : IDeadLetterQueueReplayer, IDisposable

IDeadLetterQueueReplayer for Amazon SQS: drains a queue’s dead-letter queue and re-sends each message to the main queue with a reset delivery budget (a new send resets the native ApproximateReceiveCount, and the carried attempt counter is dropped) so it is redelivered after the underlying defect is fixed. Each message is re-sent (broker-confirmed) before its dead-letter copy is deleted, so a crash mid-replay duplicates rather than loses — duplicates are absorbed by the consumer’s inbox dedup.

Constructors

AmazonSqsDeadLetterReplayer(IOptions<AmazonSqsOptions> options, ILogger<AmazonSqsDeadLetterReplayer> logger)

Methods

Task<int> ReplayAsync(string queueName, int maxMessages = 100, CancellationToken cancellationToken = default(CancellationToken))

Replays up to maxMessages messages from queueName’s dead-letter queue back onto queueName. Each message is re-enqueued (confirmed by the broker) before its DLQ copy is acknowledged, so a crash mid-replay duplicates rather than loses — duplicates are absorbed by the consumer’s inbox dedup. Returns the number replayed.

void Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

AmazonSqsMessageBroker

public sealed class AmazonSqsMessageBroker : IMessageBroker, IAsyncDisposable

IMessageBroker over Amazon SNS. Publishes events to an SNS topic (the “exchange”) with the routing key in a routing-key message attribute so subscribed SQS queues can filter on it; an SNS publish returns once the topic has accepted the message, so a failed publish throws and the outbox records it rather than silently dropping the event. There is no per-subscription “unroutable” signal (a message matching no subscription is simply dropped by SNS), so DetectsUnroutableMessages is false.

Constructors

AmazonSqsMessageBroker(IOptions<AmazonSqsOptions> options, ILogger<AmazonSqsMessageBroker> logger)

Methods

Task PublishAsync(MessageBrokerMessage message, CancellationToken cancellationToken = default(CancellationToken))

Publish a message to the message broker

Task PublishManyAsync(IEnumerable<MessageBrokerMessage> messages, CancellationToken cancellationToken = default(CancellationToken))

Publish multiple messages to the message broker

Task<bool> PingAsync(CancellationToken cancellationToken = default(CancellationToken))

Connectivity probe for the health check: resolves the SNS topic ARN (an idempotent CreateTopic round-trip), confirming the endpoint and credentials. Throws if SNS is unreachable.

ValueTask DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

AmazonSqsMessageConsumer

public sealed class AmazonSqsMessageConsumer : IMessageConsumer, IAsyncDisposable

IMessageConsumer over Amazon SQS. A Relay “queue” is an SQS queue subscribed to the SNS topic (raw message delivery) with a filter policy on the routing key (no keys ⇒ catch-all). Consumes by long-polling and deletes a message only after the handler succeeds, so with the inbox it yields exactly-once processing on top of at-least-once delivery.

Retry / poison. SQS counts deliveries natively (ApproximateReceiveCount); a scheduled-redelivery copy is a fresh send whose native count resets, so it carries the incremented attempt count in the x-relay-delivery-attempts header instead. On failure the message’s visibility is shortened so it is redelivered after a delay (native delay) until AmazonSqsOptions.MaxDeliveryAttempts is reached, after which it is sent to a companion dead-letter queue and deleted from the main queue. The registered IMessageErrorPolicy, consume filters and IConsumerRedeliveryScheduler compose as for the other transports.

The AWS SDK retries connections internally, so this does not implement IMessageConsumerLifecycle — the host waits passively.

Constructors

AmazonSqsMessageConsumer(IOptions<AmazonSqsOptions> options, ILogger<AmazonSqsMessageConsumer> logger, IMessageErrorPolicy? errorPolicy = null, IEnumerable<IConsumeFilter>? consumeFilters = null, IConsumerRedeliveryScheduler? redeliveryScheduler = null)

Methods

Task SubscribeAsync(string queueName, IReadOnlyCollection<string> routingKeys, Func<MessageBrokerMessage, CancellationToken, Task> handler, CancellationToken cancellationToken = default(CancellationToken))
ValueTask DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

AmazonSqsOptions

public sealed class AmazonSqsOptions : MessageBrokerOptions

Connection and topology options for the Amazon SQS/SNS transport.

Relay’s exchange/routing-key SPI maps onto AWS as: events publish to an SNS topic (AmazonSqsOptions.TopicName) with the routing key in a routing-key message attribute; a Relay “queue” is an SQS queue subscribed to the topic (raw message delivery) with an SNS filter policy on the routing key (no routing keys ⇒ no filter ⇒ catch-all). SQS provides native delivery counting (ApproximateReceiveCount), visibility-timeout redelivery, and a companion dead-letter queue. All Relay metadata travels in a JSON relay_meta message attribute.

Properties

int MaxDeliveryAttempts { get; set; }

Maximum delivery attempts before a message is routed to its dead-letter queue.

int MaxNumberOfMessages { get; set; }

Maximum messages fetched per receive call (1–10).

int VisibilityTimeoutSeconds { get; set; }

Visibility timeout (seconds) for an in-flight message; also the delay before a failed message is redelivered.

int WaitTimeSeconds { get; set; }

Long-poll wait (seconds) per receive call.

string QueuePrefix { get; set; }

Prefix for the per-queue SQS queue names (<prefix>-<queue>).

string Region { get; set; }

AWS region system name (e.g. us-east-1).

string TopicName { get; set; }

SNS topic events are published to (the “exchange”).

string? AccessKey { get; set; }

Access key id. Defaults to the standard credential chain when null (set explicitly for LocalStack).

string? SecretKey { get; set; }

Secret access key. Defaults to the standard credential chain when null.

string? ServiceUrl { get; set; }

Service URL override (e.g. http://localhost:4566 for LocalStack). Null uses real AWS endpoints.

Nuvora.Nexus.Relay.Messaging.AmazonSqs.DependencyInjection

AmazonSqsServiceCollectionExtensions

public static class AmazonSqsServiceCollectionExtensions

Registration helpers for the Amazon SQS/SNS message transport. Interchangeable with the other Relay transports — the outbox/inbox processors work unchanged.

Methods

static IServiceCollection AddRelayAmazonSqs(this IServiceCollection services, Action<AmazonSqsOptions> configure)

Nuvora.Nexus.Relay.Messaging.AmazonSqs.HealthChecks

AmazonSqsHealthCheck

public sealed class AmazonSqsHealthCheck : IHealthCheck

Health check for Amazon SQS/SNS connectivity: probes the broker with a bounded timeout, so an unreachable broker surfaces as Unhealthy instead of only as outbox publish failures.

Constructors

AmazonSqsHealthCheck(IMessageBroker broker)

Methods

Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default(CancellationToken))

Runs the health check, returning the status of the component being checked.

AmazonSqsHealthCheckBuilderExtensions

public static class AmazonSqsHealthCheckBuilderExtensions

Health-check registration for the Amazon SQS/SNS broker connection.

Methods

static IHealthChecksBuilder AddRelayAmazonSqs(this IHealthChecksBuilder builder, string name = "relay-amazonsqs", IEnumerable<string>? tags = null)

Adds the Amazon SQS/SNS connectivity health check (5s bound). Wire it into the readiness endpoint: services.AddHealthChecks().AddRelayAmazonSqs().