发送消息到mq

This commit is contained in:
qiminbao
2025-08-25 18:03:16 +08:00
parent 94856a31e8
commit d4846a8848
2 changed files with 3 additions and 3 deletions
@@ -46,7 +46,7 @@ public class AgentDecoderHandler extends ChannelInboundHandlerAdapter {
if (msg instanceof ByteBuf) {
ByteBuf byteBuf = (ByteBuf) msg;
String messages = byteBuf.toString(CharsetUtil.UTF_8); // 指定字符集解码
// AssertLog.info("<<[up1]:IP:{},[up-content]==>{}", sessionManager.client(ctx),messages);
AssertLog.info("<<[up1]:IP:{},[up-content]==>{}", sessionManager.client(ctx),messages);
String content = "";
boolean isClear = false;
@@ -91,7 +91,7 @@ public class AgentDecoderHandler extends ChannelInboundHandlerAdapter {
content = tempMsg + messages;
isClear = true;
}
AssertLog.info("<<[up]:IP:{},[up-content]==>{}", sessionManager.client(ctx),content);
AssertLog.info("<<[up2]:IP:{},[up-content]==>{}", sessionManager.client(ctx),content);
endsWith = content.endsWith("@tong-ran");
//判断是否是整包
if(endsWith){
@@ -37,7 +37,7 @@ public class AgentEncoderHandler extends ChannelOutboundHandlerAdapter {
return;
}
AssertLog.info(">>[down]:IP:{},[content]==>{}", sessionManager.client(ctx), entity.getData());
String json = "agent-server:"+JSON.toJSONString(entity)+"@tong-ran";
String json = JSON.toJSONString(entity);
byte[] bytes = json.getBytes(StandardCharsets.UTF_8); // 显式指定 UTF-8
// byte[] bytes = EscapeUtil.hexStringToByteArray(entity.getContent());
ByteBuf buf = Unpooled.wrappedBuffer(bytes);