From 5830d0265f1da0f06a8c059e89667228da28e898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A4=A7=E7=9F=B3=E5=A4=B4?= Date: Sat, 29 Jun 2024 21:27:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83=E6=97=B6=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89Json=E5=BA=8F=E5=88=97=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NewLife.RocketMQ/Producer.cs | 3 +++ NewLife.RocketMQ/Protocol/Command.cs | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NewLife.RocketMQ/Producer.cs b/NewLife.RocketMQ/Producer.cs index bb1a144..4b9a682 100644 --- a/NewLife.RocketMQ/Producer.cs +++ b/NewLife.RocketMQ/Producer.cs @@ -1,4 +1,5 @@ using NewLife.Log; +using NewLife.Reflection; using NewLife.RocketMQ.Client; using NewLife.RocketMQ.Common; using NewLife.RocketMQ.Models; @@ -396,6 +397,8 @@ protected virtual Message CreateMessage(Object body) if (body is null) throw new ArgumentNullException(nameof(body)); if (body is Message) throw new ArgumentOutOfRangeException(nameof(body), "body不能是Message类型"); + if (!body.GetType().IsBaseType()) body = JsonHost.Write(body); + var msg = new Message(); msg.SetBody(body); diff --git a/NewLife.RocketMQ/Protocol/Command.cs b/NewLife.RocketMQ/Protocol/Command.cs index 0382908..755049f 100644 --- a/NewLife.RocketMQ/Protocol/Command.cs +++ b/NewLife.RocketMQ/Protocol/Command.cs @@ -167,7 +167,7 @@ public Boolean Write(Stream stream, Object context = null) { // 计算头部 //var json = Header.ToJson(); - var json = JsonWriter.ToJson(Header, false, false, false); + var json = Header.ToJson(false, false, false); var hs = json.GetBytes(); // 计算长度