Add RabbitMQ-based email publisher and DI support
Introduced `OutgoingEmailPublisher` for RabbitMQ-based email queueing with message persistence, scalability, and reliability. Added dependency injection support via `AddMessagingServicePublisher` extension method. Enhanced RabbitMQ topology setup with exchanges, queues, and Dead Letter Queues (DLQ). Updated `DigitalData.MessagingService.Publisher.csproj` and `DigitalData.MessagingService.RabbitMQ.csproj` to support `net462`, `net480`, and `net8.0`. Added project references and conditional package references for compatibility. Integrated logging with `Microsoft.Extensions.Logging` and used `System.Text.Json` for serialization. Implemented lazy initialization for RabbitMQ channels to improve performance.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using DigitalData.MessagingService.Publisher.Abstraction;
|
||||
using DigitalData.MessagingService.RabbitMQ;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace DigitalData.MessagingService.Publisher;
|
||||
|
||||
public static class DependencyInjection
|
||||
{
|
||||
public static IServiceCollection AddMessagingServicePublisher(this IServiceCollection services, Action<Configuration>? configure = null)
|
||||
{
|
||||
if(configure is not null)
|
||||
{
|
||||
var configuration = new Configuration(services);
|
||||
configure(configuration);
|
||||
}
|
||||
|
||||
// --- Email Queue (RabbitMQ) ---
|
||||
services.AddSingleton<IOutgoingEmailPublisher, OutgoingEmailPublisher>();
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
public class Configuration
|
||||
{
|
||||
private readonly IServiceCollection _services;
|
||||
internal Configuration(IServiceCollection services)
|
||||
{
|
||||
_services = services;
|
||||
}
|
||||
|
||||
public Configuration AddRabbitMqConnectionFactory(IConfiguration configuration)
|
||||
{
|
||||
_services.AddRabbitMqConnectionFactory(configuration);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user