惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Proofpoint News Feed
Blog — PlanetScale
Blog — PlanetScale
GbyAI
GbyAI
C
Check Point Blog
腾讯CDC
Stack Overflow Blog
Stack Overflow Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The GitHub Blog
The GitHub Blog
A
About on SuperTechFans
Recent Announcements
Recent Announcements
L
LangChain Blog
Microsoft Azure Blog
Microsoft Azure Blog
小众软件
小众软件
J
Java Code Geeks
博客园_首页
Jina AI
Jina AI
美团技术团队
H
Help Net Security
MyScale Blog
MyScale Blog
Engineering at Meta
Engineering at Meta
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
人人都是产品经理
人人都是产品经理
Y
Y Combinator Blog
S
SegmentFault 最新的问题

博客园 - 三驾马车

Claude Code 官宣:可以在 IDEA 用了! idea gitee 更新已取消 解决方案 ByteBuffer和ByteBuf区别 Marshalling.getProvidedMarshallerFactory("serial") 参数有那些 protobuf 的 Varint 编码规范 netty initChannel ch.pipeline().addLast 先后顺序很重要 ChannelInboundHandlerAdapter 的channelRead和channelReadComplete的区别 Unpooled.buffer()和Unpooled.copiedBuffer区别 ServerBootstrap 和Bootstrap 区别 childhandler 和 handler 区别 ChannelInitializer<SocketChannel> 的作用详解 ChannelHandlerAdapter 和 ChannelInboundHandlerAdapter 的区别 SimpleChannelInboundHandler 中的 messageReceived 和 channelRead0 ChannelHandlerAdapter 与 ChannelInboundHandler 的区别 Application run failed .ParserException: while parsing a block mapping in 'reader' openssl genrsa 自签名ssl证书 上传本地项目到新建git项目 save download pdf
ProtobufVarint32FrameDecoder和ProtobufDecoder区别
三驾马车 · 2025-05-21 · via 博客园 - 三驾马车

1. ProtobufVarint32FrameDecoder 的输出是 去除了 Varint32 长度头的纯 protobuf 消息体,确保:

  1. 消息完整性(无粘包/半包问题)。

  2. 直接适配 ProtobufDecoder 的输入要求。

2. ProtobufDecoder 用于处理 Protocol Buffers (protobuf) 二进制数据的解码器,其 处理后的结果是将字节流(ByteBuf)转换为具体的 Java 对象(即 protobuf 生成的 Message 子类)

  1. 接收前驱解码器的输出

    • 前驱通常是 ProtobufVarint32FrameDecoder,负责提供完整的消息体(不含长度前缀)。

  2. 解析二进制数据

    • 根据 protoc 生成的 Java 类(如 MyMessage),将 ByteBuf 反序列化为对象。

  3. 传递对象给下一个处理器

                 输出解码后的对象,供后续 ChannelHandler(如业务处理器)使用。

ProtobufDecoder 的输出是 完全解析后的 protobuf Java 对象,其核心作用包括:

  1. 二进制 → 对象转换:将网络字节流反序列化为内存中的结构化数据。

  2. 与业务逻辑衔接:直接提供可操作的对象,避免手动解析。