API reference — Transports
Nuvora.Nexus.Relay.Messaging.AzureServiceBus
Azure Service Bus message transport for Nuvora Nexus Relay
dotnet add package Nuvora.Nexus.Relay.Messaging.AzureServiceBus
Nuvora.Nexus.Relay.Messaging.AzureServiceBus
AzureServiceBusDeadLetterReplayer
public sealed class AzureServiceBusDeadLetterReplayer : IDeadLetterQueueReplayer, IAsyncDisposable
IDeadLetterQueueReplayer for Azure Service Bus: drains a subscription’s native dead-letter queue and republishes each message to the topic (resetting its delivery count) so it is redelivered after the underlying defect is fixed. Each message is re-enqueued (and confirmed by the SDK) before its dead-letter copy is completed, so a crash mid-replay duplicates rather than loses — duplicates are absorbed by the consumer’s inbox dedup.
Constructors
AzureServiceBusDeadLetterReplayer(IOptions<AzureServiceBusOptions> options, ILogger<AzureServiceBusDeadLetterReplayer> 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.
ValueTask DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
AzureServiceBusMessageBroker
public sealed class AzureServiceBusMessageBroker : IMessageBroker, IAsyncDisposable
IMessageBroker over Azure Service Bus. Publishes events to a single topic (AzureServiceBusOptions.TopicName) with the Relay routing key carried in the message Subject; subscribers filter on it. The Service Bus SDK sender is thread-safe and pools AMQP links internally, so one shared sender is reused (no per-publish channel pool as with RabbitMQ).
Durable retry/dead-lettering is owned by the outbox, so this performs only a short in-call retry for transient blips, on top of the SDK’s own transport retries. Unlike RabbitMQ there is no “unroutable” signal: a publish to a topic with no matching subscription succeeds and is dropped by the broker — reflected by DetectsUnroutableMessages = false in the transport capabilities.
Constructors
AzureServiceBusMessageBroker(IOptions<AzureServiceBusOptions> options, ILogger<AzureServiceBusMessageBroker> 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: opens an AMQP link to the topic (creating an empty message batch forces the connection) without sending anything. Throws if the namespace is unreachable.
ValueTask DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
AzureServiceBusMessageConsumer
public sealed class AzureServiceBusMessageConsumer : IMessageConsumer, IAsyncDisposable
IMessageConsumer over Azure Service Bus. A Relay “queue” is a subscription on the shared topic; routing keys become correlation rules on the subscription’s Subject. Consumes with a ServiceBusProcessor in PeekLock mode and manual completion: a message is completed only after the handler succeeds, so combined with the inbox it yields exactly-once processing on top of at-least-once delivery.
Poison messages. Service Bus tracks delivery attempts natively (ServiceBusReceivedMessage.DeliveryCount). On handler failure the message is abandoned (redelivered) until AzureServiceBusOptions.MaxDeliveryAttempts is reached, then dead-lettered into the subscription’s native dead-letter queue. The registered IMessageErrorPolicy, consume filters and IConsumerRedeliveryScheduler compose exactly as they do for RabbitMQ.
Recovery. ServiceBusProcessor recovers transient faults internally, so this consumer does not implement IMessageConsumerLifecycle — the host waits passively while the processor keeps delivering (capability SupportsConsumerLifecycle = false).
Constructors
AzureServiceBusMessageConsumer(IOptions<AzureServiceBusOptions> options, ILogger<AzureServiceBusMessageConsumer> 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.
AzureServiceBusOptions
public sealed class AzureServiceBusOptions : MessageBrokerOptions
Connection and topology options for the Azure Service Bus transport.
Relay’s broker SPI is exchange/routing-key shaped (RabbitMQ-style). It maps onto Service Bus as: events publish to a single AzureServiceBusOptions.TopicName with the routing key carried in the message Subject (Service Bus’s label); a Relay “queue” is a Service Bus subscription on that topic, and the routing keys passed to SubscribeAsync become correlation rules on the subscription’s Subject (no routing keys ⇒ the catch-all default rule).
Properties
int MaxConcurrentCalls { get; set; }
Maximum messages a single subscription processor handles concurrently (Service Bus MaxConcurrentCalls). Composes with the concurrency-limiter consume filter.
int MaxDeliveryAttempts { get; set; }
Maximum delivery attempts before a message is moved to the subscription’s dead-letter queue. Maps onto the Service Bus subscription’s native MaxDeliveryCount when entities are auto-created.
int PrefetchCount { get; set; }
Messages prefetched per processor. Bounds memory under a slow handler; 0 disables prefetch.
object? Credential { get; set; }
Token credential for AzureServiceBusOptions.FullyQualifiedNamespace auth (e.g. DefaultAzureCredential). Typed as Object so the options type carries no hard dependency on Azure.Identity; it must be an Azure.Core.TokenCredential at runtime.
string TopicName { get; set; }
Topic events are published to (analogous to the RabbitMQ exchange).
string? ConnectionString { get; set; }
Connection string for the namespace (Endpoint=sb://…;SharedAccessKeyName=…;SharedAccessKey=…). Takes precedence over AzureServiceBusOptions.FullyQualifiedNamespace when set.
string? FullyQualifiedNamespace { get; set; }
Fully-qualified namespace (my-namespace.servicebus.windows.net) for token-credential auth. Used with AzureServiceBusOptions.Credential when AzureServiceBusOptions.ConnectionString is not set.
Nuvora.Nexus.Relay.Messaging.AzureServiceBus.DependencyInjection
AzureServiceBusServiceCollectionExtensions
public static class AzureServiceBusServiceCollectionExtensions
Registration helpers for the Azure Service Bus message transport. Interchangeable with AddRelayRabbitMq / AddRelayInMemoryTransport — the outbox/inbox processors work unchanged.
Methods
static IServiceCollection AddRelayAzureServiceBus(this IServiceCollection services, Action<AzureServiceBusOptions> configure)
Nuvora.Nexus.Relay.Messaging.AzureServiceBus.HealthChecks
AzureServiceBusHealthCheck
public sealed class AzureServiceBusHealthCheck : IHealthCheck
Health check for Azure Service Bus connectivity: opens an AMQP link to the topic with a bounded timeout, so an unreachable namespace surfaces as Unhealthy instead of only as outbox publish failures.
Constructors
AzureServiceBusHealthCheck(IMessageBroker broker)
Methods
Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default(CancellationToken))
Runs the health check, returning the status of the component being checked.
AzureServiceBusHealthCheckBuilderExtensions
public static class AzureServiceBusHealthCheckBuilderExtensions
Health-check registration for the Azure Service Bus broker connection.
Methods
static IHealthChecksBuilder AddRelayAzureServiceBus(this IHealthChecksBuilder builder, string name = "relay-azureservicebus", IEnumerable<string>? tags = null)
Adds the Azure Service Bus connectivity health check (5s bound). Wire it into the readiness endpoint: services.AddHealthChecks().AddRelayAzureServiceBus().