From 45f1d54cfb21e6b7d7542e9ad4efc035ff10edd1 Mon Sep 17 00:00:00 2001 From: Savorboard Date: Sun, 19 Jan 2020 14:01:27 +0800 Subject: [PATCH 1/3] Try to fix azure service bus header cast exception. #483 --- .../AzureServiceBusConsumerClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DotNetCore.CAP.AzureServiceBus/AzureServiceBusConsumerClient.cs b/src/DotNetCore.CAP.AzureServiceBus/AzureServiceBusConsumerClient.cs index 06f1486..0f97419 100644 --- a/src/DotNetCore.CAP.AzureServiceBus/AzureServiceBusConsumerClient.cs +++ b/src/DotNetCore.CAP.AzureServiceBus/AzureServiceBusConsumerClient.cs @@ -159,7 +159,7 @@ namespace DotNetCore.CAP.AzureServiceBus private Task OnConsumerReceived(Message message, CancellationToken token) { - var header = message.UserProperties.ToDictionary(x => x.Key, y => y.Value.ToString()); + var header = message.UserProperties.ToDictionary(x => x.Key, y => y.Value?.ToString()); var context = new TransportMessage(header, message.Body); From 4991c388d3f0166773caf90d81319707c1b4b2bb Mon Sep 17 00:00:00 2001 From: Savorboard Date: Mon, 20 Jan 2020 10:50:16 +0800 Subject: [PATCH 2/3] Fix SqlException: Invalid column name 'id' for COLLATION Turkish_CI_AS. #491 --- src/DotNetCore.CAP.SqlServer/IMonitoringApi.SqlServer.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/DotNetCore.CAP.SqlServer/IMonitoringApi.SqlServer.cs b/src/DotNetCore.CAP.SqlServer/IMonitoringApi.SqlServer.cs index 86432d1..a4391ec 100644 --- a/src/DotNetCore.CAP.SqlServer/IMonitoringApi.SqlServer.cs +++ b/src/DotNetCore.CAP.SqlServer/IMonitoringApi.SqlServer.cs @@ -175,7 +175,7 @@ select count(Id) from {_recName} with (nolock) where StatusName = N'Failed';"; var sqlQuery2008 = $@" with aggr as ( select replace(convert(varchar, Added, 111), '/','-') + '-' + CONVERT(varchar, DATEPART(hh, Added)) as [Key], - count(id) [Count] + count(Id) [Count] from {tableName} where StatusName = @statusName group by replace(convert(varchar, Added, 111), '/','-') + '-' + CONVERT(varchar, DATEPART(hh, Added)) @@ -186,7 +186,7 @@ select [Key], [Count] from aggr with (nolock) where [Key] in @keys;"; var sqlQuery = $@" with aggr as ( select FORMAT(Added,'yyyy-MM-dd-HH') as [Key], - count(id) [Count] + count(Id) [Count] from {tableName} where StatusName = @statusName group by FORMAT(Added,'yyyy-MM-dd-HH') From 0838a23da1aeb6fdaec629d7d051eb667818dc7c Mon Sep 17 00:00:00 2001 From: Andrew Jaffie Date: Thu, 30 Jan 2020 02:49:58 -0500 Subject: [PATCH 3/3] Add capability to optionally set kafka message key via new header (#498) --- src/DotNetCore.CAP.Kafka/ITransport.Kafka.cs | 2 +- src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs | 2 ++ src/DotNetCore.CAP.Kafka/KafkaHeaders.cs | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/DotNetCore.CAP.Kafka/KafkaHeaders.cs diff --git a/src/DotNetCore.CAP.Kafka/ITransport.Kafka.cs b/src/DotNetCore.CAP.Kafka/ITransport.Kafka.cs index aec7d39..60bcea7 100644 --- a/src/DotNetCore.CAP.Kafka/ITransport.Kafka.cs +++ b/src/DotNetCore.CAP.Kafka/ITransport.Kafka.cs @@ -43,7 +43,7 @@ namespace DotNetCore.CAP.Kafka var result = await producer.ProduceAsync(message.GetName(), new Message { Headers = headers, - Key = message.GetId(), + Key = message.Headers.TryGetValue(KafkaHeaders.KafkaKey, out string kafkaMessageKey) && !string.IsNullOrEmpty(kafkaMessageKey) ? kafkaMessageKey : message.GetId(), Value = message.Body }); diff --git a/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs b/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs index dd18f21..28b7137 100644 --- a/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs +++ b/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs @@ -62,6 +62,8 @@ namespace DotNetCore.CAP.Kafka } headers.Add(Messages.Headers.Group, _groupId); + headers.Add(KafkaHeaders.KafkaKey, consumerResult.Key); + if (_kafkaOptions.CustomHeaders != null) { var customHeaders = _kafkaOptions.CustomHeaders(consumerResult); diff --git a/src/DotNetCore.CAP.Kafka/KafkaHeaders.cs b/src/DotNetCore.CAP.Kafka/KafkaHeaders.cs new file mode 100644 index 0000000..350fa2b --- /dev/null +++ b/src/DotNetCore.CAP.Kafka/KafkaHeaders.cs @@ -0,0 +1,10 @@ +// Copyright (c) .NET Core Community. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +namespace DotNetCore.CAP.Kafka +{ + public static class KafkaHeaders + { + public const string KafkaKey = "cap-kafka-key"; + } +}