API reference — Transports

Nuvora.Nexus.Relay.Messaging.ValKey

ValKey Streams message transport for Nuvora Nexus Relay (works with any Redis-compatible server)

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

Nuvora.Nexus.Relay.Messaging.ValKey

ValKeyDeadLetterReplayer

public sealed class ValKeyDeadLetterReplayer : IDeadLetterQueueReplayer, IAsyncDisposable

IDeadLetterQueueReplayer for ValKey Streams: reads a group’s dead-letter stream and re-appends each entry to the group’s retry stream (which the group consumes) with a reset delivery budget, so it is reprocessed after the underlying defect is fixed. A dedicated, stable consumer group tracks how far the dead-letter stream has been drained, so repeated replays never re-emit an entry already replayed. Each entry is re-appended before it is acked, so a crash mid-replay duplicates rather than loses — duplicates are absorbed by the consumer’s inbox dedup.

Constructors

ValKeyDeadLetterReplayer(IOptions<ValKeyOptions> options, ILogger<ValKeyDeadLetterReplayer> logger, ValKeyTransportConnection? connection = null)

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.

ValueTask DisposeAsync()

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

ValKeyMessageBroker

public sealed class ValKeyMessageBroker : IMessageBroker, IAsyncDisposable

IMessageBroker over ValKey Streams. Publishes events to a stream (the “exchange”) with the routing key as an entry field; XADD is acknowledged by the server before the call completes, so a failed publish throws and the outbox records it rather than silently dropping the event. Publishes trim the stream approximately (MAXLEN ~) per ValKeyOptions.MaxStreamLength. There is no per-consumer “unroutable” signal (every consumer group reads the whole stream), so DetectsUnroutableMessages is false.

Constructors

ValKeyMessageBroker(IOptions<ValKeyOptions> options, ILogger<ValKeyMessageBroker> logger, ValKeyTransportConnection? connection = null)

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: pings the server over the shared connection. Throws if the server is unreachable.

ValueTask DisposeAsync()

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

ValKeyMessageConsumer

public sealed class ValKeyMessageConsumer : IMessageConsumer, IAsyncDisposable

IMessageConsumer over ValKey Streams. A Relay “queue” is a consumer group (group name = the queue name) that reads the event stream plus its own retry stream; routing keys are filtered client-side. Ack ≡ XACK after the handler succeeds, so with the inbox it yields exactly-once processing on top of at-least-once delivery.

Retry / poison. Streams have no per-message nack, dead-letter queue or delayed delivery, so a failed message is republished to the group’s retry stream (which the same group consumes) with an incremented attempt count — and, once ValKeyOptions.MaxDeliveryAttempts is reached, to the group’s dead-letter stream. The original entry is acked either way so the group keeps moving (no head-of-line blocking). The registered IMessageErrorPolicy, consume filters and IConsumerRedeliveryScheduler compose as for the other transports; delayed retries need a redelivery scheduler since streams have no native delay.

Crash recovery. An entry delivered to a consumer that died before acking stays in the group’s pending list; every consumer periodically claims entries idle longer than ValKeyOptions.ClaimMinIdleTime via XAUTOCLAIM and reprocesses them. The client multiplexer reconnects internally, so the consumer exposes no IMessageConsumerLifecycle signal.

Constructors

ValKeyMessageConsumer(IOptions<ValKeyOptions> options, ILogger<ValKeyMessageConsumer> logger, IMessageErrorPolicy? errorPolicy = null, IEnumerable<IConsumeFilter>? consumeFilters = null, IConsumerRedeliveryScheduler? redeliveryScheduler = null, ValKeyTransportConnection? connection = 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.

ValKeyOptions

public sealed class ValKeyOptions : MessageBrokerOptions

Connection and topology options for the ValKey Streams transport (StackExchange.Redis client; works against ValKey or any Redis-compatible server).

ValKey Streams are an append-only log with consumer groups, so the exchange/routing-key SPI maps the same way as Kafka’s: events publish to a ValKeyOptions.StreamName (the “exchange”) with the routing key as an entry field; a Relay “queue” is a consumer group (group name = the queue name) that independently reads the stream, with routing keys filtered client-side. Streams have no per-consumer dead-letter queue or delayed delivery, so failures are republished to a per-group retry stream (same group consumes it) with an incremented attempt count and, at the cap, to a per-group dead-letter stream. Ack ≡ XACK. Entries a crashed consumer never acked are reclaimed by its group peers via XAUTOCLAIM after ValKeyOptions.ClaimMinIdleTime.

Properties

TimeSpan ClaimInterval { get; set; }

How often each consumer scans for abandoned pending entries to claim.

TimeSpan ClaimMinIdleTime { get; set; }

How long a pending (delivered but unacked) entry must sit idle before another consumer of the group may claim it via XAUTOCLAIM — the crash-recovery window. Must comfortably exceed the longest expected handler run, or a slow handler’s message is processed twice.

bool ReadFromEarliest { get; set; }

Where a new consumer group starts reading when it is first created: the beginning of the stream (true) or only entries appended after creation (false).

int BatchSize { get; set; }

Maximum entries fetched per XREADGROUP call.

int MaxDeliveryAttempts { get; set; }

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

int PollDelayMs { get; set; }

Delay between empty polls (milliseconds). StackExchange.Redis multiplexes one connection and does not support blocking reads (XREADGROUP BLOCK), so the consumer polls at this cadence.

long MaxStreamLength { get; set; }

Approximate cap on stream length, enforced on publish (XADD MAXLEN ~). Streams retain entries after every group acked them, so unbounded streams grow forever; 0 disables trimming. Size the cap so the slowest consumer group cannot fall further behind than it.

string ConnectionString { get; set; }

StackExchange.Redis connection string (e.g. localhost:6379).

string StreamName { get; set; }

Stream events are published to (the “exchange”).

ValKeyTransportConnection

public sealed class ValKeyTransportConnection : IAsyncDisposable

Owns the one multiplexed ValKey connection shared by the broker, consumer and dead-letter replayer (StackExchange.Redis is designed around a single shared multiplexer per endpoint). Connects lazily on first use with abortConnect=false, so a ValKey outage at startup surfaces as publish/consume errors (which the outbox and poll loops retry) rather than failing host startup.

Constructors

ValKeyTransportConnection(IOptions<ValKeyOptions> options)

Methods

ValueTask DisposeAsync()

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

ValueTask<IConnectionMultiplexer> GetConnectionAsync(CancellationToken cancellationToken = default(CancellationToken))
ValueTask<IDatabase> GetDatabaseAsync(CancellationToken cancellationToken = default(CancellationToken))

The default database of the shared connection, connecting on first call.

Nuvora.Nexus.Relay.Messaging.ValKey.DependencyInjection

ValKeyServiceCollectionExtensions

public static class ValKeyServiceCollectionExtensions

Registration helpers for the ValKey Streams message transport. Interchangeable with the other Relay transports — the outbox/inbox processors work unchanged.

Methods

static IServiceCollection AddRelayValKey(this IServiceCollection services, Action<ValKeyOptions> configure)

Nuvora.Nexus.Relay.Messaging.ValKey.HealthChecks

ValKeyHealthCheck

public sealed class ValKeyHealthCheck : IHealthCheck

Health check for ValKey connectivity: probes the server with a bounded timeout, so an unreachable server surfaces as Unhealthy instead of only as outbox publish failures.

Constructors

ValKeyHealthCheck(IMessageBroker broker)

Methods

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

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

ValKeyHealthCheckBuilderExtensions

public static class ValKeyHealthCheckBuilderExtensions

Health-check registration for the ValKey broker connection.

Methods

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

Adds the ValKey connectivity health check (5s bound). Wire it into the readiness endpoint: services.AddHealthChecks().AddRelayValKey().