API reference — Transports

Nuvora.Nexus.Relay.Messaging.Pulsar

Apache Pulsar message transport for Nuvora Nexus Relay

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

Nuvora.Nexus.Relay.Messaging.Pulsar

PulsarDeadLetterReplayer

public sealed class PulsarDeadLetterReplayer : IDeadLetterQueueReplayer, IAsyncDisposable

IDeadLetterQueueReplayer for Apache Pulsar: drains a queue’s dead-letter topic and republishes each message to the event topic (resetting the delivery budget) so it is redelivered after the underlying defect is fixed. Each message is re-published (and the Pulsar send confirmed) before its dead-letter copy is acked, so a crash mid-replay duplicates rather than loses — duplicates are absorbed by the consumer’s inbox dedup.

Constructors

PulsarDeadLetterReplayer(IOptions<PulsarOptions> options, ILogger<PulsarDeadLetterReplayer> 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.

PulsarMessageBroker

public sealed class PulsarMessageBroker : IMessageBroker, IAsyncDisposable

IMessageBroker over Apache Pulsar (DotPulsar). Publishes events to a single topic with the routing key carried in a message property; a Pulsar Send only completes once the broker has persisted the message and returned its id, so a failed publish throws and the outbox records it rather than silently dropping the event. The DotPulsar producer is thread-safe, so one shared producer is reused. There is no per-subscription “unroutable” signal (every shared subscription receives the message), so DetectsUnroutableMessages is false.

Constructors

PulsarMessageBroker(IOptions<PulsarOptions> options, ILogger<PulsarMessageBroker> 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: waits until the producer reaches the Connected state.

ValueTask DisposeAsync()

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

PulsarMessageConsumer

public sealed class PulsarMessageConsumer : IMessageConsumer, IAsyncDisposable

IMessageConsumer over Apache Pulsar (DotPulsar). A Relay “queue” is a named shared subscription on the event topic; routing keys are filtered client-side (DotPulsar consumers are single-topic, so non-matching events are acked and skipped). Consumes with manual ack: a message is acked only after the handler succeeds, so with the inbox it yields exactly-once processing on top of at-least-once delivery.

Retry / poison. The low-level client has no negative-ack or DLQ policy, so a failed delivery is republished to the event topic with an incremented attempt count (and the original acked) — using Pulsar’s native DeliverAtTime for delayed redelivery — until PulsarOptions.MaxDeliveryAttempts is reached, after which it is published to the dead-letter topic. The registered IMessageErrorPolicy, consume filters and IConsumerRedeliveryScheduler compose exactly as for the other transports.

Deliveries are processed sequentially per consumer; the client recovers connections internally, so this does not implement IMessageConsumerLifecycle — the host waits passively.

Constructors

PulsarMessageConsumer(IOptions<PulsarOptions> options, ILogger<PulsarMessageConsumer> 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.

PulsarOptions

public sealed class PulsarOptions : MessageBrokerOptions

Connection and topology options for the Apache Pulsar transport (DotPulsar client).

Relay’s exchange/routing-key SPI maps onto Pulsar as: events publish to a single PulsarOptions.TopicName; the routing key travels in a message property. A Relay “queue” is a named shared subscription on that topic — each subscription independently receives every event, and the consumer filters by routing key client-side (DotPulsar consumers are single-topic, so there is no server-side routing-key filter). Pulsar has no DLQ policy in the low-level client, so poison messages are republished to a PulsarOptions.DeadLetterTopicName and delayed redelivery uses native DeliverAtTime.

Properties

int MaxConcurrentCalls { get; set; }

Maximum messages a single consumer processes concurrently (composes with the concurrency-limiter consume filter).

int MaxDeliveryAttempts { get; set; }

Maximum delivery attempts before a message is routed to the dead-letter topic.

string DeadLetterTopicName { get; set; }

Topic poison messages are routed to.

string Namespace { get; set; }

Pulsar namespace.

string ServiceUrl { get; set; }

Pulsar broker service URL (e.g. pulsar://localhost:6650).

string Tenant { get; set; }

Pulsar tenant.

string TopicName { get; set; }

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

Nuvora.Nexus.Relay.Messaging.Pulsar.DependencyInjection

PulsarServiceCollectionExtensions

public static class PulsarServiceCollectionExtensions

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

Methods

static IServiceCollection AddRelayPulsar(this IServiceCollection services, Action<PulsarOptions> configure)

Nuvora.Nexus.Relay.Messaging.Pulsar.HealthChecks

PulsarHealthCheck

public sealed class PulsarHealthCheck : IHealthCheck

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

Constructors

PulsarHealthCheck(IMessageBroker broker)

Methods

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

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

PulsarHealthCheckBuilderExtensions

public static class PulsarHealthCheckBuilderExtensions

Health-check registration for the Apache Pulsar broker connection.

Methods

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

Adds the Apache Pulsar connectivity health check (5s bound). Wire it into the readiness endpoint: services.AddHealthChecks().AddRelayPulsar().