Skip to content

Commit

Permalink
发布时使用自定义Json序列化
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Jun 29, 2024
1 parent d5b1acf commit 5830d02
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions NewLife.RocketMQ/Producer.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NewLife.Log;
using NewLife.Reflection;
using NewLife.RocketMQ.Client;
using NewLife.RocketMQ.Common;
using NewLife.RocketMQ.Models;
Expand Down Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion NewLife.RocketMQ/Protocol/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

// 计算长度
Expand Down

0 comments on commit 5830d02

Please sign in to comment.