feat: expose RabbitMQ delivery context

Add backward-compatible context-aware handling and permanent validation hooks.

Ref: IT-1033
This commit is contained in:
2026-08-02 22:56:57 +03:00
parent 09c4b8b4d2
commit c0e83bdb77
4 changed files with 264 additions and 6 deletions
+13 -1
View File
@@ -6,10 +6,22 @@ RabbitMQ publisher and consumer base for HrynCo applications.
- `RabbitMqSettings` — connection settings record (host, port, user, password, virtual host)
- `IRabbitMqPublisher` / `RabbitMqPublisher` — publishes JSON-serialized messages to a named queue
- `RabbitMqConsumerBase<TMessage, TMessageData>` abstract background service base for consumers, with retry + dead-letter support
- `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.