Files
DigitalData.MessagingService/src/infrastructure/DigitalData.MessagingService.RabbitMQ/RabbitMqConfiguration.cs
TekH fa9b4973b9 Introduce RabbitMQ consumer pool for parallel processing
Enhanced RabbitMQ email processing by introducing a `SendingEmailConsumerPool` to enable the competing consumers pattern. Each consumer operates on its own channel, improving scalability and thread safety.

- Added `SendingEmailConsumerPool` to manage multiple consumers.
- Updated `DependencyInjection` to register the consumer pool.
- Refactored `SendingEmailConsumer` for better logging and error handling.
- Updated `AsyncInitWorker` to initialize the consumer pool.
- Added `ConsumerConcurrency` to RabbitMQ configuration.
- Improved error handling in `LimilabsEmailService` with detailed SMTP error messages.
2026-08-05 15:34:33 +02:00

85 lines
3.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
namespace DigitalData.MessagingService.RabbitMQ
{
/// <summary>
/// Configuration for RabbitMQ connection
/// </summary>
public class RabbitMqConfiguration
{
/// <summary>
/// Configuration section name in appsettings.json
/// </summary>
public const string SectionName = "RabbitMQ";
/// <summary>
/// RabbitMQ server hostname
/// </summary>
public string HostName { get; set; } = "localhost";
/// <summary>
/// RabbitMQ AMQP port (default: 5672)
/// </summary>
public int Port { get; set; } = 5672;
/// <summary>
/// RabbitMQ username
/// </summary>
public string UserName { get; set; } = "guest";
/// <summary>
/// RabbitMQ password
/// </summary>
public string Password { get; set; } = "guest";
/// <summary>
/// Virtual host (default: /)
/// </summary>
public string VirtualHost { get; set; } = "/";
/// <summary>
/// Enable automatic recovery on connection failure
/// </summary>
public bool AutomaticRecoveryEnabled { get; set; } = true;
/// <summary>
/// Network recovery interval in seconds
/// </summary>
public int NetworkRecoveryIntervalSeconds { get; set; } = 10;
/// <summary>
/// Name of the main queue where outbound email messages are consumed from.
/// </summary>
public string QueueName { get; set; } = "messaging-service.email.outbox";
/// <summary>
/// Name of the exchange to which email messages are published.
/// Messages are routed from this exchange to <see cref="QueueName"/> via <see cref="RoutingKey"/>.
/// </summary>
public string ExchangeName { get; set; } = "messaging-service.emails";
/// <summary>
/// Routing key used to bind <see cref="QueueName"/> to <see cref="ExchangeName"/>.
/// </summary>
public string RoutingKey { get; set; } = "email.outbox";
/// <summary>
/// Name of the Dead Letter Queue (DLQ) where messages that could not be processed are routed.
/// </summary>
public string DlqQueueName { get; set; } = "messaging-service.email.outbox.dlq";
/// <summary>
/// Name of the Dead Letter Exchange (DLX) that routes rejected or expired messages to <see cref="DlqQueueName"/>.
/// </summary>
public string DlqExchangeName { get; set; } = "messaging-service.emails.dlq";
/// <summary>
/// Routing key used to bind <see cref="DlqQueueName"/> to <see cref="DlqExchangeName"/>.
/// </summary>
public string DlqRoutingKey { get; set; } = "email.outbox.dlq";
/// <summary>
/// Maximum number of email messages processed concurrently by the consumer.
/// Maps directly to RabbitMQ prefetchCount. Recommended: 35.
/// </summary>
public ushort ConsumerConcurrency { get; set; } = 5;
}
}