- Add EmailSender class with ConnectRabbitMq and Send methods
- Add OnReconnect enum for reconnection behavior control
- Add required NuGet packages (DependencyInjection, Hosting.Abstractions)
- Add project references to Publisher.Abstraction and Publisher
Replaced direct registration of `OutgoingEmailPublisher` with `AddMessagingServicePublisher()` to centralize publisher setup. Removed `OutgoingEmailPublisher.cs` and its dependencies, indicating a shift to a new implementation. Updated `DependencyInjection.cs` to use `DigitalData.MessagingService.Publisher` instead of the abstraction layer. Added a project reference to `DigitalData.MessagingService.Publisher` in the infrastructure project file.
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.
Reorganized project structure by introducing `core` and
`infrastructure` directories:
- Moved `Application` and `Domain` projects to `core`.
- Moved `Infrastructure` project to `infrastructure`.
Updated project references in `API`, `Infrastructure`, and
`Application` projects to reflect the new directory structure.
Added a new dependency on `Publisher.Abstraction` in the
`Application` project.
A new project, `DigitalData.MessagingService.Publisher`, has been added to the solution. The solution file (`DigitalData.MessagingService.sln`) was updated to include the project declaration, build configurations, and nesting under the appropriate parent project.
The new project targets `.NET 8.0` and includes the following configurations:
- Implicit Usings enabled.
- Nullable reference types enabled.
- Latest C# language version specified.
Added `<ImplicitUsings>` property with the value `enable` to both `DigitalData.MessagingService.Publisher.Abstraction.csproj` and `DigitalData.MessagingService.Client.DependencyInjection.csproj` to enable implicit global using directives. Adjusted the order of `<LangVersion>` to follow `<Nullable>` for consistency.
A new project, `DigitalData.MessagingService.Client.DependencyInjection`, has been added to the solution.
- Updated `DigitalData.MessagingService.sln` to include the new project with its build configurations and nested project structure.
- Created `DigitalData.MessagingService.Client.DependencyInjection.csproj` targeting `net462`, `net480`, and `net8.0`.
- Added project metadata such as `PackageId`, `Authors`, `Version`, and more.
- Included a dependency on `RabbitMQ.Client` (v7.2.1).
- Configured nullable reference types and set the language version to `latest`.
- Added `icon.png` for NuGet packaging and enabled XML documentation generation.
Reorganized the solution structure to align with a layered architecture:
- Replaced `src` folder with `core`, `infrastructure`, and `presentation`.
- Moved projects to their respective folders.
- Added `DigitalData.MessagingService.Publisher.Abstraction` project.
- Removed `DigitalData.MessagingService.Client` project.
Updated project configurations and nesting in the solution file.
Added `appsettings.Secrets.json` with RabbitMQ and email account settings:
- RabbitMQ configuration includes hostname, port, credentials, and queue/exchange details.
- Email configuration includes SMTP server details and credentials.
The following projects were removed:
- `DigitalData.MessagingService.Client.Infrastructure`
- `DigitalData.MessagingService.Client`
- `DigitalData.MessagingService.Publisher.Abstraction`
The solution file (`DigitalData.MessagingService.sln`) was updated to remove references to these projects, including solution configuration platforms and nested project sections.
Additionally, the `DigitalData.MessagingService.Application.csproj` file was updated to remove a `ProjectReference` to `DigitalData.MessagingService.Publisher.Abstraction.csproj`.
These changes streamline the solution by removing unused or redundant components and reducing dependencies.
Introduced a new project, `DigitalData.MessagingService.Publisher.Abstraction`, to encapsulate the `OutgoingEmailEvent` class and `IOutgoingEmailPublisher` interface. The project targets multiple frameworks (`net462`, `net480`, `net8.0`) and enables nullable reference types and the latest C# language version.
Moved `OutgoingEmailEvent` and `IOutgoingEmailPublisher` to the new project, updating their namespaces and replacing `required` properties with mutable ones in `OutgoingEmailEvent`. Updated all dependent files to reference the new namespace.
Updated the solution file to include the new project and adjusted build configurations. Cleaned up unused `using` directives and removed redundant `LangVersion` property in the new project file.
A new project, `DigitalData.MessagingService.Client.Infrastructure`, has been added to the solution. This project targets `net462` and `net8.0`, with Implicit Usings, Nullable reference types, and the latest C# language version enabled. It includes dependencies on `Microsoft.Extensions.Logging.Abstractions`, `RabbitMQ.Client`, and `Microsoft.Extensions.Options.ConfigurationExtensions`.
The solution file has been updated to include the new project, along with its build configurations (Debug and Release for Any CPU). The project hierarchy has also been updated to reflect the addition of the new project and the reassignment of the `DigitalData.MessagingService.Client` project to a different parent group.
Refactored the registration of `RabbitMqConnectionFactory` and
RabbitMQ configuration into a new `AddRabbitMqConnectionFactory`
extension method for improved modularity and reusability.
- Removed direct calls to `AddSingleton<RabbitMqConnectionFactory>`
and `Configure<RabbitMqConfiguration>` from the main
`DependencyInjection` class.
- Added a new static `DependencyInjection` class under the
`DigitalData.MessagingService.RabbitMQ` namespace.
- The new `AddRabbitMqConnectionFactory` method encapsulates
RabbitMQ DI logic and accepts `IServiceCollection` and
`IConfiguration` as parameters.
- Updated `DependencyInjection.cs` to use the new extension method.
Updated the `<TargetFrameworks>` property to include `net480`
to support .NET Framework 4.8. Added `<LangVersion>` set to
`latest` to use the latest C# language features. Enabled
nullable reference types by adding `<Nullable>` set to
`enable` for improved null safety.
- Added null-safety checks (`?.`) for `ILogger` usage in `OutgoingEmailConsumer`.
- Removed unused `AsyncEventingBasicConsumer` and `_lazyInit` fields.
- Updated `DisposeAsync` to check `_lazyChannel.IsValueCreated` before accessing it.
- Added infinite delay in `AsyncInitWorker` to keep the background service active until cancellation.
- Improved overall maintainability and reduced potential runtime issues.
Updated the project to target .NET 8.0 alongside .NET Framework 4.6.2.
Added `<LangVersion>` property set to `latest` to enable the use of
the latest C# language features. Existing `<ImplicitUsings>` and
`<Nullable>` properties remain unchanged. No changes were made to
the `MediatR` package reference.
Refactored the `OutgoingEmailConsumer` class to improve maintainability, readability, and robustness. Changed the class to explicitly inherit from `IAsyncDisposable` and introduced lazy initialization for RabbitMQ connections and consumers via `_lazyInit`.
Enhanced error handling in `consumer.ReceivedAsync` by adding detailed logging, `BasicNack` for invalid messages, and placeholders for error reporting strategies. Improved logging for consumer startup and added safeguards against multiple initializations.
Removed outdated comments, updated documentation, and ensured proper resource cleanup in `DisposeAsync`.
Updated the project file to support multi-targeting for both
.NET Framework 4.6.2 and .NET 8.0 by replacing `<TargetFramework>`
with `<TargetFrameworks>`.
Reformatted `AuthenticationFailedException` and
`NotFoundException` classes to use braces `{ }` for namespaces
and constructors for consistency. No functional changes were made
to the exception classes.
Significantly restructured the `DigitalData.MessagingService.Domain` project by removing unused domain-specific classes, enums, and value objects. Key changes include:
- Updated `ExceptionHandlingMiddleware` to handle `FluentValidation.ValidationException` with formatted validation errors mapped to `HttpStatusCode.BadRequest`.
- Removed foundational domain classes such as `BaseEntity`, `ValueObject`, and `IAggregateRoot`.
- Deleted enums (`AttachmentStatus`, `AuthenticationType`, `EmailStatus`, `ErrorCode`, `ProcessType`) and domain exceptions (`DomainException`, `AttachmentProcessingException`, `DmsNotAvailableException`, `InvalidPdfException`, `ValidationException`).
- Removed value objects (`EmailAddress`, `MessageId`) and the `MessageIdGenerator` service.
- Cleaned up the project structure by removing the `Events` folder reference.
These changes simplify the domain model, reduce unused code, and align the project with updated architectural goals.
Refactored `OutgoingEmailConsumer` and `OutgoingEmailPublisher` to use `Lazy<Task<IChannel>>` for channel initialization, ensuring channels are created only when needed. Simplified initialization and disposal logic by centralizing channel management.
Replaced `CancellationTokenSource` in both classes with the `CancellationToken` provided by `RabbitMqConnectionFactory`, centralizing token management. Updated methods to use the new lazy initialization pattern.
Removed `RabbitMqConnectionFactory.InitAsync` and introduced `CreateChannelAsync` and `CreateConsumerAsync` methods for simplified channel and consumer creation. Managed cancellation tokens internally with a `CancellationTokenSource`.
Simplified `AsyncInitWorker` by removing dependencies on `RabbitMqConnectionFactory` and `OutgoingEmailPublisher`. Removed redundant initialization logic.
Cleaned up unused imports, improved logging consistency, and enhanced code readability and maintainability.
Updated `OutgoingEmailConsumer` and `OutgoingEmailPublisher` to use `GetDefaultConnectionAsync` instead of `GetConnectionAsync` for initializing RabbitMQ connections.
Renamed `GetConnectionAsync` to `GetDefaultConnectionAsync` in `RabbitMqConnectionFactory` to improve clarity and align with naming conventions. Updated `InitAsync` in `RabbitMqConnectionFactory` to use the renamed method.
These changes improve consistency, maintainability, and clarity in RabbitMQ connection management.
Moved RabbitMQ-related functionality from the
`DigitalData.MessagingService.Infrastructure` project to a new
dedicated project/namespace `DigitalData.MessagingService.RabbitMQ`.
- Updated `DependencyInjection.cs` to use the new namespace.
- Added a project reference to `RabbitMQ.csproj` in the
`Infrastructure.csproj` file.
- Removed `RabbitMqConfiguration.cs` and `RabbitMqConnectionFactory.cs`
from the `Infrastructure` project.
- Updated namespaces in `OutgoingEmailConsumer.cs`,
`OutgoingEmailPublisher.cs`, and `AsyncInitWorker.cs` to use
`DigitalData.MessagingService.RabbitMQ`.
This refactor improves modularity, maintainability, and separation
of concerns by isolating RabbitMQ functionality in its own project.
Added support for RabbitMQ integration:
- Updated project to target `net462` and `net8.0`.
- Added NuGet dependencies: `RabbitMQ.Client`, `Microsoft.Extensions.Logging.Abstractions`, and `Microsoft.Extensions.Options.ConfigurationExtensions`.
- Introduced `RabbitMqConfiguration` class for managing RabbitMQ settings.
- Implemented `RabbitMqConnectionFactory` for creating and managing RabbitMQ connections with lazy initialization, async disposal, and logging support.
Updated `DigitalData.MessagingService.Client.csproj`:
- Added NuGet metadata (PackageId, Authors, Company, etc.).
- Included `icon.png` as the package icon.
- Configured multi-targeting for `net462` and `net8.0`.
- Added XML documentation file generation.
Added `icon.png` binary file to the project.
Simplified `DigitalData.MessagingService.Client.csproj` by removing metadata properties and adding a `RabbitMQ.Client` package reference.
Added a new project `DigitalData.MessagingService.RabbitMQ` targeting `net462` and `net8.0` with a `RabbitMQ.Client` package reference.
Updated `DigitalData.MessagingService.sln` to reflect the new project structure, including new paths, GUIDs, and solution configuration mappings.
The `MailKit` package reference (version 4.17.0) was removed from the `DigitalData.MessagingService.Infrastructure.csproj` file. This change suggests that the functionality provided by `MailKit` is no longer required or has been replaced by an alternative solution.
A new project `DigitalData.MessagingService.Client` has been added, targeting `net462` and `net8.0`. The project includes metadata for packaging and distribution, such as `PackageId`, `Authors`, `Version`, and more.
The solution file `DigitalData.MessagingService.sln` has been updated to include the new project, with build configurations for `Debug|Any CPU` and `Release|Any CPU`. The project is nested under the `infrastructure` folder in the solution structure.
Added three new projects ("presentation", "core", and
"infrastructure") to the solution file with unique GUIDs.
Updated the `GlobalSection(NestedProjects)` to reflect the
new project structure, nesting the new projects under the
parent project with GUID `{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}`.
Removed outdated nested project mappings and replaced them
with mappings for the new projects. Updated the solution
file to ensure proper integration of the new projects.
The `MimeKit` package reference (version `4.17.0`) has been removed from the `DigitalData.MessagingService.Application.csproj` file. This change indicates that the project no longer relies on the `MimeKit` library for its functionality.
Simplified the codebase by removing the `IOutgoingEmailConsumer` interface and directly using the `OutgoingEmailConsumer` class.
- Removed `IOutgoingEmailConsumer` from the application.
- Updated `DependencyInjection` to register `OutgoingEmailConsumer` directly.
- Modified `OutgoingEmailConsumer` to no longer implement the removed interface.
- Updated `AsyncInitWorker` to depend directly on `OutgoingEmailConsumer`.
- Simplified initialization logic for email consumer and publisher.
These changes eliminate an unnecessary abstraction layer, making the code easier to maintain while preserving functionality.
Refactored the RabbitMQ-based email queue system by splitting
`OutgoingEmailQueue` into `OutgoingEmailPublisher` and
`OutgoingEmailConsumer` to separate publishing and consuming
responsibilities.
- Introduced `IOutgoingEmailConsumer` and renamed
`IOutgoingEmailQueue` to `IOutgoingEmailPublisher` for clarity.
- Updated `SendEmailCommandHandler` to use the new publisher
abstraction.
- Added `RabbitMqConnectionFactory` to centralize RabbitMQ
connection management.
- Updated dependency injection to register new services.
- Simplified RabbitMQ initialization logic by delegating it to
`RabbitMqConnectionFactory`.
- Enhanced logging for better observability.
- Improved modularity and maintainability by separating concerns
between message publishing and consuming.
Refactored the `OutgoingEmailQueue` class to use separate RabbitMQ
channels for publishing and consuming, improving thread safety and
aligning with RabbitMQ best practices. Replaced the synchronous
`Dispose` method with an asynchronous `DisposeAsync` for proper
cleanup of resources.
Introduced a `CancellationTokenSource` to manage the consumer's
lifetime independently, ensuring graceful shutdown. Updated the
`InitAsync` method to initialize dedicated channels and adjusted
RabbitMQ topology declarations to use the publish channel.
Replaced `_logger` with the injected `Logger` instance for
consistency and updated RabbitMQ operations to use the appropriate
channels with cancellation token support. Improved error handling
and logging in the consumer, and ensured acknowledgments operate
on the consume channel.
Simplified the class structure by removing redundant fields and
adopting C# 12 primary constructor syntax. Adjusted method
parameters for clarity and added comments to explain design
decisions. These changes enhance maintainability, scalability,
and reliability.
Removed `InitAsync` from `IOutgoingEmailQueue` to decouple RabbitMQ initialization from the interface. Replaced `AsyncIniteWorker` with the correctly named `AsyncInitWorker` in `DependencyInjection.cs` and introduced a new, improved implementation of `AsyncInitWorker`.
The new `AsyncInitWorker` class initializes the outgoing email queue consumer using an event-driven RabbitMQ approach, with enhanced logging and error handling. Removed the outdated `AsyncIniteWorker` class to streamline the codebase.
These changes improve code clarity, maintainability, and correctness.
Removed EmailSenderWorker and its configuration, including
EmailSenderWorkerConfiguration. Introduced AsyncIniteWorker
as a replacement, simplifying the design by removing
configuration-based toggling.
- Deleted EmailSenderWorkerConfiguration.cs.
- Removed EmailSenderWorker and its registration from Program.cs.
- Registered AsyncIniteWorker in DependencyInjection.cs.
- Renamed and refactored EmailSenderWorker to AsyncIniteWorker.
- Updated namespace and removed unused configuration dependencies.
Removed `DequeueAsync` from `IOutgoingEmailQueue` and added `GetQueueDepthAsync` to query the queue's message count. Updated RabbitMQ connection and channel creation methods to support `CancellationToken`. Removed `DequeueAsync` implementation from `OutgoingEmailQueue`, signaling a shift away from direct message consumption. These changes improve cancellation handling and simplify the queue's responsibilities.
Renamed the `IEmailQueue` interface to `IOutgoingEmailQueue` to improve clarity and better reflect its purpose as an outgoing email queue. Updated all references to the interface across the codebase, including:
- Replaced `IEmailQueue` with `IOutgoingEmailQueue` in `EmailSenderWorker.cs`.
- Renamed the interface in `IOutgoingEmailQueue.cs`.
- Updated `SendEmailCommandHandler` in `SendEmailCommand.cs` to use `IOutgoingEmailQueue`.
- Modified dependency injection in `DependencyInjection.cs` to register `OutgoingEmailQueue` with `IOutgoingEmailQueue`.
- Updated `OutgoingEmailQueue.cs` to implement `IOutgoingEmailQueue`.
These changes improve code readability, maintainability, and naming consistency.
Replaced `RabbitMqEmailQueue` with `OutgoingEmailQueue` in the
dependency injection container to reflect the updated class name.
Renamed the class `RabbitMqEmailQueue` to `OutgoingEmailQueue`
in `OutgoingEmailQueue.cs`, including updates to the constructor
and logger type. This refactor aligns the class name with its
purpose and improves clarity in the codebase.
Centralized email processing logic in `RabbitMqEmailQueue` by moving it from `EmailSenderWorker`. Updated `IEmailQueue` to replace `StartConsumerAsync` with `InitAsync`, shifting to an initialization-based model for RabbitMQ.
Refactored `RabbitMqEmailQueue` to handle email processing inline, including deserialization, logging, and sending emails via `IEmailService`. Enhanced error handling with detailed logging for failures. Removed lazy initialization (`Lazy<Task>`) in favor of explicit initialization via `InitAsync`.
Simplified `EmailSenderWorker` by removing `ProcessEmailAsync` and its dependency on `IEmailService`. Updated it to call `EmailQueue.InitAsync` for initialization.
Improved logging and error handling for better visibility into email processing and failure scenarios. Updated RabbitMQ acknowledgment and rejection logic to use `args.CancellationToken`.
Updated `RabbitMqConfiguration` to include properties for queue and exchange names, replacing hardcoded constants in `RabbitMqEmailQueue`. All RabbitMQ operations now use dynamic values from the configuration object, improving flexibility and configurability. Updated logging to reflect these changes.
The application no longer uses RabbitMQ for command publishing and consumption. This commit removes all RabbitMQ-related code, including:
- Removed RabbitMQ service registrations in `DependencyInjection.cs`.
- Deleted `RabbitMqCommandConsumer.cs`, which implemented a background service for consuming commands.
- Deleted `RabbitMqCommandPublisher.cs`, which implemented a publisher for RabbitMQ-based commands.
- Removed RabbitMQ-specific properties (`ExchangeName`, `QueueName`, `RoutingKey`) from `RabbitMqConfiguration.cs`.
These changes reflect a shift in the application's messaging strategy or architecture.
Introduced a dedicated `EmailSenderWorkerConfiguration` class to centralize and simplify configuration management for the `EmailSenderWorker`. Updated `Program.cs` to use this class for dependency injection and removed the inline configuration logic from `EmailSenderWorker.cs`.
Simplified the worker's constructor by leveraging `IOptions<EmailSenderWorkerConfiguration>`. Removed the unused `MaxRetryCount` property from the configuration class and `appsettings.json`.
Cleaned up `using` directives in `Program.cs` and `EmailSenderWorker.cs` to include the new namespace and remove redundant imports. These changes improve maintainability and align with best practices.
Added a reference to the `System.Security.Cryptography.Xml`
package (version 10.0.10) in the project file to enable
XML cryptographic operations such as signing, verifying,
and encrypting XML data. This change enhances the project's
capabilities for handling secure XML processing.
Replaced the `EncryptedPassword` property in `EmailAccountDto` with `Password` and `PasswordEncrypted` to support both plain text and encrypted passwords. Updated `LimilabsEmailService` to use the new properties, checking the `PasswordEncrypted` flag to determine whether decryption is needed.
The `EmailAccount` section has been removed entirely, including
properties such as `Username`, `SmtpServer`, `SmtpPort`,
`SmtpUseSsl`, and `UseOAuth2`. No changes were made to the
`EmailSender` section or the `LuckyPennySoftLicenseKey`.
Refactored `EmailAccountDto` to focus on SMTP-related properties, removing unused fields. Updated `DependencyInjection` to configure data protection with a new key storage path. Simplified `DataProtectionEncryptionService` by removing redundant checks and error handling for encryption and decryption methods.
- Add static constructor to register System.Text.Encoding.CodePages
- Required for windows-1252 and other extended code page support
- Fixes encoding issues with international email content
- Add license key reading from appsettings.json
- Configure AutoMapper 16.2.0+ with built-in DI extension and license key
- Configure MediatR 14.2.0+ with license key
- Update Program.cs to pass IConfiguration to AddApplicationServices