Files
hrynco-rabbitmq/Hrynco.RabbitMq
agrynco c0e83bdb77 feat: expose RabbitMQ delivery context
Add backward-compatible context-aware handling and permanent validation hooks.

Ref: IT-1033
2026-08-02 22:56:57 +03:00
..

HrynCo.RabbitMq

RabbitMQ publisher and consumer base for HrynCo applications.

Contents

  • RabbitMqSettings — connection settings record (host, port, user, password, virtual host)
  • IRabbitMqPublisher / RabbitMqPublisher — publishes JSON-serialized messages to a named queue
  • RabbitMqConsumerBase<TMessage, TMessageData> — background service base with connection management, manual ACK/NACK, retry, permanent-validation rejection, and backward-compatible context-aware handling
  • RabbitMqMessageContext — neutral AMQP delivery metadata (MessageId, type, correlation, routing, headers, and redelivery state)
  • IRabbitMqMessage<TMessageData> — message contract interface
  • CorrelationContext — correlation ID carrier

Packaging

This package is intended for reuse through NuGet. The test project is excluded from packing.

Consumer extension points

Existing consumers can keep overriding HandleMessageAsync(message, cancellationToken). Consumers that need AMQP metadata can instead override HandleMessageAsync(message, context, cancellationToken). The base class retains ownership of acknowledgements and retries.

Override TryValidateMessage(...) for application-specific permanent validation. Returning false nacks the delivery without requeue before retry processing begins. Keep validation errors free of credentials and sensitive payload values.