Files
hrynco-rabbitmq/Hrynco.RabbitMq/README.md
T
agrynco a26777ca21 chore: preserve current workspace changes
Save pending configuration, deployment, and documentation work.
2026-10-03 00:56:29 +03:00

2.0 KiB

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.

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.

Package repository metadata points to HrynCo.RabbitMq on Gitea. The hostname change does not alter package versions or messaging behavior.