# 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` — 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` — 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. Override `HandleMessageRetriesExhaustedAsync(...)` when a consumer must react once to a terminal processing failure, for example by publishing a neutral failure result to the requesting client. The hook runs after the final handler exception and before the original delivery is nacked without requeue. Hook failures are logged and do not replace the original failure or acknowledgement policy. Application shutdown cancellation does not invoke the hook.