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(); // 计算长度