diff --git a/README.md b/README.md index 3eb81ff..74df490 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,8 @@ builder.Services.AddRabbitMqClient(Configuration); "UserName": "", "Password": "", "ExchangeName": "", - "VirtualHost": "" + "VirtualHost": "", + "Port": -1 } ``` diff --git a/src/Basic.RabbitMQ/Extensions/ServiceCollectionExtensions.cs b/src/Basic.RabbitMQ/Extensions/ServiceCollectionExtensions.cs index 4e4cdac..476ef55 100644 --- a/src/Basic.RabbitMQ/Extensions/ServiceCollectionExtensions.cs +++ b/src/Basic.RabbitMQ/Extensions/ServiceCollectionExtensions.cs @@ -28,6 +28,7 @@ private static void CreateServices( UserName = messageBrokerOptions.Username, Password = messageBrokerOptions.Password, VirtualHost = messageBrokerOptions.VirtualHost, + Port = messageBrokerOptions.Port is default(int) ? AmqpTcpEndpoint.UseDefaultPort : messageBrokerOptions.Port, DispatchConsumersAsync = true, AutomaticRecoveryEnabled = true, NetworkRecoveryInterval = TimeSpan.FromSeconds(30), diff --git a/src/Basic.RabbitMQ/Options/MessageBrokerOptions.cs b/src/Basic.RabbitMQ/Options/MessageBrokerOptions.cs index 06df36b..c419b2e 100644 --- a/src/Basic.RabbitMQ/Options/MessageBrokerOptions.cs +++ b/src/Basic.RabbitMQ/Options/MessageBrokerOptions.cs @@ -7,4 +7,5 @@ public class MessageBrokerOptions public string Password { get; set; } public string ExchangeName { get; set; } public string VirtualHost { get; set; } + public int Port { get; set; } } \ No newline at end of file