@@ -3,11 +3,11 @@ | |||||
using System; | using System; | ||||
using System.Collections.Concurrent; | using System.Collections.Concurrent; | ||||
using System.Text.Json; | |||||
using System.Threading; | using System.Threading; | ||||
using Confluent.Kafka; | using Confluent.Kafka; | ||||
using Microsoft.Extensions.Logging; | using Microsoft.Extensions.Logging; | ||||
using Microsoft.Extensions.Options; | using Microsoft.Extensions.Options; | ||||
using Newtonsoft.Json; | |||||
namespace DotNetCore.CAP.Kafka | namespace DotNetCore.CAP.Kafka | ||||
{ | { | ||||
@@ -24,7 +24,7 @@ namespace DotNetCore.CAP.Kafka | |||||
_producerPool = new ConcurrentQueue<IProducer<string, byte[]>>(); | _producerPool = new ConcurrentQueue<IProducer<string, byte[]>>(); | ||||
_maxSize = _options.ConnectionPoolSize; | _maxSize = _options.ConnectionPoolSize; | ||||
logger.LogDebug("Kafka configuration of CAP :\r\n {0}", JsonSerializer.Serialize(_options.AsKafkaConfig())); | |||||
logger.LogDebug("Kafka configuration of CAP :\r\n {0}", JsonConvert.SerializeObject(_options.AsKafkaConfig())); | |||||
} | } | ||||
public string ServersAddress => _options.Servers; | public string ServersAddress => _options.Servers; | ||||
@@ -13,8 +13,8 @@ | |||||
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" /> | <PackageReference Include="JetBrains.Annotations" Version="2019.1.3" /> | ||||
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.0.0" /> | <PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.0.0" /> | ||||
<PackageReference Include="Microsoft.Extensions.Options" Version="3.0.0" /> | <PackageReference Include="Microsoft.Extensions.Options" Version="3.0.0" /> | ||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" /> | |||||
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.6.0" /> | <PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.6.0" /> | ||||
<PackageReference Include="System.Text.Json" Version="4.6.0" /> | |||||
</ItemGroup> | </ItemGroup> | ||||
</Project> | </Project> |
@@ -1,7 +1,11 @@ | |||||
using System; | |||||
// Copyright (c) .NET Core Community. All rights reserved. | |||||
// Licensed under the MIT License. See License.txt in the project root for license information. | |||||
using System; | |||||
using System.Text; | |||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using DotNetCore.CAP.Messages; | using DotNetCore.CAP.Messages; | ||||
using System.Text.Json; | |||||
using Newtonsoft.Json; | |||||
namespace DotNetCore.CAP.Serialization | namespace DotNetCore.CAP.Serialization | ||||
{ | { | ||||
@@ -9,7 +13,8 @@ namespace DotNetCore.CAP.Serialization | |||||
{ | { | ||||
public Task<TransportMessage> SerializeAsync(Message message) | public Task<TransportMessage> SerializeAsync(Message message) | ||||
{ | { | ||||
return Task.FromResult(new TransportMessage(message.Headers, JsonSerializer.SerializeToUtf8Bytes(message.Value))); | |||||
var json = JsonConvert.SerializeObject(message.Value); | |||||
return Task.FromResult(new TransportMessage(message.Headers, Encoding.UTF8.GetBytes(json))); | |||||
} | } | ||||
public Task<Message> DeserializeAsync(TransportMessage transportMessage, Type valueType) | public Task<Message> DeserializeAsync(TransportMessage transportMessage, Type valueType) | ||||
@@ -19,7 +24,8 @@ namespace DotNetCore.CAP.Serialization | |||||
return Task.FromResult(new Message(transportMessage.Headers, null)); | return Task.FromResult(new Message(transportMessage.Headers, null)); | ||||
} | } | ||||
return Task.FromResult(new Message(transportMessage.Headers, JsonSerializer.Deserialize(transportMessage.Body, valueType))); | |||||
var json = Encoding.UTF8.GetString(transportMessage.Body); | |||||
return Task.FromResult(new Message(transportMessage.Headers, JsonConvert.DeserializeObject(json, valueType))); | |||||
} | } | ||||
} | } | ||||
} | } |
@@ -1,4 +1,7 @@ | |||||
using System; | |||||
// Copyright (c) .NET Core Community. All rights reserved. | |||||
// Licensed under the MIT License. See License.txt in the project root for license information. | |||||
using System; | |||||
using System.Threading.Tasks; | using System.Threading.Tasks; | ||||
using DotNetCore.CAP.Messages; | using DotNetCore.CAP.Messages; | ||||
using JetBrains.Annotations; | using JetBrains.Annotations; | ||||
@@ -1,5 +1,8 @@ | |||||
using DotNetCore.CAP.Messages; | |||||
using System.Text.Json; | |||||
// Copyright (c) .NET Core Community. All rights reserved. | |||||
// Licensed under the MIT License. See License.txt in the project root for license information. | |||||
using DotNetCore.CAP.Messages; | |||||
using Newtonsoft.Json; | |||||
namespace DotNetCore.CAP.Serialization | namespace DotNetCore.CAP.Serialization | ||||
{ | { | ||||
@@ -7,12 +10,12 @@ namespace DotNetCore.CAP.Serialization | |||||
{ | { | ||||
public static string Serialize(Message message) | public static string Serialize(Message message) | ||||
{ | { | ||||
return JsonSerializer.Serialize(message); | |||||
return JsonConvert.SerializeObject(message); | |||||
} | } | ||||
public static Message DeSerialize(string json) | public static Message DeSerialize(string json) | ||||
{ | { | ||||
return JsonSerializer.Deserialize<Message>(json); | |||||
return JsonConvert.DeserializeObject<Message>(json); | |||||
} | } | ||||
} | } | ||||
} | } |