diff --git a/src/presentation/DigitalData.MessagingService.Client.DependencyInjection/EmailSender.cs b/src/presentation/DigitalData.MessagingService.Client.DependencyInjection/EmailSender.cs
index 1bd51a3..72b191e 100644
--- a/src/presentation/DigitalData.MessagingService.Client.DependencyInjection/EmailSender.cs
+++ b/src/presentation/DigitalData.MessagingService.Client.DependencyInjection/EmailSender.cs
@@ -2,6 +2,7 @@
using DigitalData.MessagingService.Publisher.Abstraction;
using DigitalData.MessagingService.RabbitMQ;
using Microsoft.Extensions.DependencyInjection;
+using System;
namespace DigitalData.MessagingService.Client.DependencyInjection;
@@ -71,6 +72,39 @@ public static class EmailSender
_ = LazyProvider.Value; // Force initialization
}
+ ///
+ /// Configures and establishes a connection to RabbitMQ using a URL, then initializes
+ /// the internal dependency injection container.
+ ///
+ ///
+ /// The RabbitMQ server URL (e.g. amqp://hostname:5672/virtualhost).
+ /// The host, port, and virtual host are extracted from this URL.
+ ///
+ /// The username used to authenticate with RabbitMQ.
+ /// The password used to authenticate with RabbitMQ.
+ ///
+ /// Controls the behavior when this method is called while already connected.
+ /// Defaults to .
+ ///
+ ///
+ /// Thrown when the service is already connected and
+ /// is .
+ ///
+ public static void ConnectRabbitMq(string url, string username, string password, OnReconnect onReconnect = OnReconnect.ThrowException)
+ {
+ var uri = new Uri(url);
+
+ ConnectRabbitMq(cfg =>
+ {
+ cfg.HostName = uri.Host;
+ cfg.Port = uri.IsDefaultPort ? 5672 : uri.Port;
+ cfg.UserName = username;
+ cfg.Password = password;
+ if (!string.IsNullOrEmpty(uri.AbsolutePath) && uri.AbsolutePath != "/")
+ cfg.VirtualHost = Uri.UnescapeDataString(uri.AbsolutePath.TrimStart('/'));
+ }, onReconnect);
+ }
+
///
/// Enqueues the specified email event to the RabbitMQ messaging pipeline.
///