API reference — Transports
Nuvora.Nexus.Relay.Messaging.Nms
JMS/NMS message transport for Nuvora Nexus Relay (Apache ActiveMQ "classic" and ActiveMQ Artemis)
dotnet add package Nuvora.Nexus.Relay.Messaging.Nms
Nuvora.Nexus.Relay.Messaging.Nms
NmsDeadLetterReplayer
public sealed class NmsDeadLetterReplayer : IDeadLetterQueueReplayer
IDeadLetterQueueReplayer for JMS/NMS: drains a queue’s dead-letter queue and re-sends each message to the topic (resetting the delivery budget) so it is redelivered after the underlying defect is fixed. Each message is re-sent (persistent, broker-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.
Constructors
NmsDeadLetterReplayer(IConnectionFactory connectionFactory, IOptions<NmsOptions> options, ILogger<NmsDeadLetterReplayer> 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.
NmsMessageBroker
public sealed class NmsMessageBroker : IMessageBroker, IAsyncDisposable
IMessageBroker over JMS/NMS (Apache ActiveMQ “classic” and Artemis). Publishes events to a JMS topic as persistent ITextMessages with the routing key in the routing_key property; a persistent send blocks until the broker has accepted the message, so a failed publish throws and the outbox records it rather than silently dropping the event. JMS sessions are not thread-safe, so the single producer session is guarded by a gate (sends are serialized).
Constructors
NmsMessageBroker(IConnectionFactory connectionFactory, IOptions<NmsOptions> options, ILogger<NmsMessageBroker> 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: establishes (or reuses) the producer connection, which opens and starts a JMS connection to the broker. Throws if the broker is unreachable.
ValueTask DisposeAsync()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.
NmsMessageConsumer
public sealed class NmsMessageConsumer : IMessageConsumer, IAsyncDisposable
IMessageConsumer over JMS/NMS (Apache ActiveMQ “classic” and Artemis). A Relay “queue” is a durable topic subscription whose JMS selector is built from the routing keys (no keys ⇒ no selector ⇒ catch-all). Consumes with client acknowledgement: 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. On failure a copy is republished to the topic with an incremented attempt count (carried in relay_meta) and the original acked — optionally delayed via the broker’s scheduled-delivery property — until NmsOptions.MaxDeliveryAttempts is reached, after which it is sent to a per-queue dead-letter queue. The registered IMessageErrorPolicy, consume filters and IConsumerRedeliveryScheduler compose exactly as for the other transports.
JMS sessions are single-threaded, so each subscription runs a dedicated synchronous receive loop (all JMS calls stay on that thread); the async handler is awaited inline. The NMS provider recovers connections internally, so this does not implement IMessageConsumerLifecycle.
Constructors
NmsMessageConsumer(IConnectionFactory connectionFactory, IOptions<NmsOptions> options, ILogger<NmsMessageConsumer> 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.
NmsOptions
public class NmsOptions : MessageBrokerOptions
Connection and topology options shared by the JMS/NMS transports (Apache ActiveMQ “classic” over OpenWire and ActiveMQ Artemis over AMQP).
Relay’s exchange/routing-key SPI maps onto JMS as: events publish to a JMS topic (NmsOptions.TopicName) with the routing key in a routing_key property; a Relay “queue” is a durable topic subscription whose JMS message selector is built from the routing keys (no keys ⇒ no selector ⇒ catch-all). JMS property names must be valid identifiers, so all Relay metadata travels as one JSON relay_meta property (preserving header names like the claim-check pointer). Poison messages are sent to a per-queue dead-letter queue and delayed redelivery uses the broker’s scheduled-delivery property.
Properties
bool ScheduledDeliveryIsAbsolute { get; set; }
Whether NmsOptions.ScheduledDeliveryProperty expects an absolute epoch-millis timestamp (Artemis) rather than a relative delay in milliseconds (ActiveMQ classic).
int MaxDeliveryAttempts { get; set; }
Maximum delivery attempts before a message is routed to its dead-letter queue.
string BrokerUri { get; set; }
Broker URI (e.g. tcp://localhost:61616 for OpenWire, amqp://localhost:5672 for AMQP).
string ClientIdPrefix { get; set; }
Stable client-id prefix for durable subscriptions (suffixed with the queue name).
string DeadLetterPrefix { get; set; }
Prefix for the per-queue dead-letter queue name (<prefix>.<queue>).
string ScheduledDeliveryProperty { get; set; }
Broker-specific scheduled-delivery property name used for delayed redelivery (AMQ_SCHEDULED_DELAY for ActiveMQ classic, _AMQ_SCHED_DELIVERY for Artemis).
string TopicName { get; set; }
JMS topic events are published to (the “exchange”).
string? Password { get; set; }
Broker password (optional).
string? Username { get; set; }
Broker username (optional).
Nuvora.Nexus.Relay.Messaging.Nms.DependencyInjection
NmsServiceCollectionExtensions
public static class NmsServiceCollectionExtensions
Registration helpers for the JMS/NMS transports. NmsServiceCollectionExtensions.AddRelayActiveMq targets Apache ActiveMQ “classic” over OpenWire; NmsServiceCollectionExtensions.AddRelayArtemis targets ActiveMQ Artemis over AMQP. Both share the same broker/consumer/replayer (the only differences are the connection factory and the scheduled-delivery property), and are interchangeable with the other Relay transports.
Methods
static IServiceCollection AddRelayActiveMq(this IServiceCollection services, Action<NmsOptions> configure)
Registers the ActiveMQ “classic” (OpenWire) transport.
static IServiceCollection AddRelayArtemis(this IServiceCollection services, Action<NmsOptions> configure)
Registers the ActiveMQ Artemis (AMQP) transport.
Nuvora.Nexus.Relay.Messaging.Nms.HealthChecks
NmsHealthCheck
public sealed class NmsHealthCheck : IHealthCheck
Health check for JMS/NMS broker connectivity (ActiveMQ “classic” or Artemis): establishes/reuses the producer connection with a bounded timeout, so an unreachable broker surfaces as Unhealthy instead of only as outbox publish failures.
Constructors
NmsHealthCheck(IMessageBroker broker)
Methods
Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default(CancellationToken))
Runs the health check, returning the status of the component being checked.
NmsHealthCheckBuilderExtensions
public static class NmsHealthCheckBuilderExtensions
Health-check registration for the JMS/NMS broker connection. Both brokers share the same broker implementation, so the methods differ only in their default name/tags.
Methods
static IHealthChecksBuilder AddRelayActiveMq(this IHealthChecksBuilder builder, string name = "relay-activemq", IEnumerable<string>? tags = null)
Adds the ActiveMQ “classic” connectivity health check (5s bound).
static IHealthChecksBuilder AddRelayArtemis(this IHealthChecksBuilder builder, string name = "relay-artemis", IEnumerable<string>? tags = null)
Adds the ActiveMQ Artemis connectivity health check (5s bound).