From 550e4adfc2a243372a72347f6fdd60067abc0e14 Mon Sep 17 00:00:00 2001 From: WuYafeng Date: Fri, 7 Jun 2019 12:34:05 +0800 Subject: [PATCH 1/3] use environment new line instead \r\n (#348) --- .../AzureServiceBusConsumerClient.cs | 6 +++--- .../IConnectionChannelPool.Default.cs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/DotNetCore.CAP.AzureServiceBus/AzureServiceBusConsumerClient.cs b/src/DotNetCore.CAP.AzureServiceBus/AzureServiceBusConsumerClient.cs index 5a26e5a..d07bc2e 100644 --- a/src/DotNetCore.CAP.AzureServiceBus/AzureServiceBusConsumerClient.cs +++ b/src/DotNetCore.CAP.AzureServiceBus/AzureServiceBusConsumerClient.cs @@ -154,9 +154,9 @@ namespace DotNetCore.CAP.AzureServiceBus { var context = args.ExceptionReceivedContext; var exceptionMessage = - $"- Endpoint: {context.Endpoint}\r\n" + - $"- Entity Path: {context.EntityPath}\r\n" + - $"- Executing Action: {context.Action}\r\n" + + $"- Endpoint: {context.Endpoint}" + Environment.NewLine + + $"- Entity Path: {context.EntityPath}" + Environment.NewLine + + $"- Executing Action: {context.Action}" + Environment.NewLine + $"- Exception: {args.Exception}"; var logArgs = new LogMessageEventArgs diff --git a/src/DotNetCore.CAP.RabbitMQ/IConnectionChannelPool.Default.cs b/src/DotNetCore.CAP.RabbitMQ/IConnectionChannelPool.Default.cs index a1fce45..7b48a01 100644 --- a/src/DotNetCore.CAP.RabbitMQ/IConnectionChannelPool.Default.cs +++ b/src/DotNetCore.CAP.RabbitMQ/IConnectionChannelPool.Default.cs @@ -42,7 +42,7 @@ namespace DotNetCore.CAP.RabbitMQ Exchange = options.ExchangeName + "." + capOptions.Version; } - _logger.LogDebug("RabbitMQ configuration of CAP :\r\n {0}", JsonConvert.SerializeObject(options, Formatting.Indented)); + _logger.LogDebug("RabbitMQ configuration of CAP :{0} {1}", Environment.NewLine, JsonConvert.SerializeObject(options, Formatting.Indented)); } IModel IConnectionChannelPool.Rent() From dc156c9b6a2ac9572b1211ce042afdbb9f5bb295 Mon Sep 17 00:00:00 2001 From: Savorboard Date: Tue, 11 Jun 2019 10:09:02 +0800 Subject: [PATCH 2/3] Remove obsolete kafka configuration. --- src/DotNetCore.CAP.Kafka/CAP.KafkaOptions.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/DotNetCore.CAP.Kafka/CAP.KafkaOptions.cs b/src/DotNetCore.CAP.Kafka/CAP.KafkaOptions.cs index 6ac3666..97d3f66 100644 --- a/src/DotNetCore.CAP.Kafka/CAP.KafkaOptions.cs +++ b/src/DotNetCore.CAP.Kafka/CAP.KafkaOptions.cs @@ -54,7 +54,6 @@ namespace DotNetCore.CAP MainConfig["bootstrap.servers"] = Servers; MainConfig["queue.buffering.max.ms"] = "10"; - MainConfig["socket.blocking.max.ms"] = "10"; MainConfig["enable.auto.commit"] = "false"; MainConfig["log.connection.close"] = "false"; MainConfig["request.timeout.ms"] = "3000"; From 316a4d76886e117659e98328a5c6aeeb458f7bb1 Mon Sep 17 00:00:00 2001 From: Savorboard Date: Fri, 14 Jun 2019 10:38:33 +0800 Subject: [PATCH 3/3] Improved RabbitMQOptions to provide extensions option to configure the client original configuration. #350 --- .../CAP.RabbiMQOptions.cs | 29 ++++++------------- .../IConnectionChannelPool.Default.cs | 10 +++---- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/src/DotNetCore.CAP.RabbitMQ/CAP.RabbiMQOptions.cs b/src/DotNetCore.CAP.RabbitMQ/CAP.RabbiMQOptions.cs index afb2fd2..d52fe61 100644 --- a/src/DotNetCore.CAP.RabbitMQ/CAP.RabbiMQOptions.cs +++ b/src/DotNetCore.CAP.RabbitMQ/CAP.RabbiMQOptions.cs @@ -2,15 +2,14 @@ // Licensed under the MIT License. See License.txt in the project root for license information. // ReSharper disable once CheckNamespace + +using System; +using RabbitMQ.Client; + namespace DotNetCore.CAP { public class RabbitMQOptions { - /// - /// Default value for connection attempt timeout, in milliseconds. - /// - public const int DefaultConnectionTimeout = 30 * 1000; - /// /// Default password (value: "guest"). /// @@ -63,21 +62,6 @@ namespace DotNetCore.CAP /// public string ExchangeName { get; set; } = DefaultExchangeName; - /// - /// Timeout setting for connection attempts (in milliseconds). - /// - public int RequestedConnectionTimeout { get; set; } = DefaultConnectionTimeout; - - /// - /// Timeout setting for socket read operations (in milliseconds). - /// - public int SocketReadTimeout { get; set; } = DefaultConnectionTimeout; - - /// - /// Timeout setting for socket write operations (in milliseconds). - /// - public int SocketWriteTimeout { get; set; } = DefaultConnectionTimeout; - /// /// The port to connect on. /// @@ -87,5 +71,10 @@ namespace DotNetCore.CAP /// Gets or sets queue message automatic deletion time (in milliseconds). Default 864000000 ms (10 days). /// public int QueueMessageExpires { get; set; } = 864000000; + + /// + /// RabbitMQ native connection factory options + /// + public Action ConnectionFactoryOptions { get; set; } } } \ No newline at end of file diff --git a/src/DotNetCore.CAP.RabbitMQ/IConnectionChannelPool.Default.cs b/src/DotNetCore.CAP.RabbitMQ/IConnectionChannelPool.Default.cs index 7b48a01..0b39f39 100644 --- a/src/DotNetCore.CAP.RabbitMQ/IConnectionChannelPool.Default.cs +++ b/src/DotNetCore.CAP.RabbitMQ/IConnectionChannelPool.Default.cs @@ -6,7 +6,6 @@ using System.Collections.Concurrent; using System.Diagnostics; using System.Threading; using Microsoft.Extensions.Logging; -using Newtonsoft.Json; using RabbitMQ.Client; namespace DotNetCore.CAP.RabbitMQ @@ -42,7 +41,7 @@ namespace DotNetCore.CAP.RabbitMQ Exchange = options.ExchangeName + "." + capOptions.Version; } - _logger.LogDebug("RabbitMQ configuration of CAP :{0} {1}", Environment.NewLine, JsonConvert.SerializeObject(options, Formatting.Indented)); + _logger.LogDebug($"RabbitMQ configuration:'HostName:{options.HostName}, Port:{options.Port}, UserName:{options.UserName}, Password:{options.Password}, ExchangeName:{options.ExchangeName}'"); } IModel IConnectionChannelPool.Rent() @@ -88,19 +87,18 @@ namespace DotNetCore.CAP.RabbitMQ UserName = options.UserName, Port = options.Port, Password = options.Password, - VirtualHost = options.VirtualHost, - RequestedConnectionTimeout = options.RequestedConnectionTimeout, - SocketReadTimeout = options.SocketReadTimeout, - SocketWriteTimeout = options.SocketWriteTimeout + VirtualHost = options.VirtualHost }; if (options.HostName.Contains(",")) { + options.ConnectionFactoryOptions?.Invoke(factory); return () => factory.CreateConnection( options.HostName.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries)); } factory.HostName = options.HostName; + options.ConnectionFactoryOptions?.Invoke(factory); return () => factory.CreateConnection(); }