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

推荐订阅源

Google DeepMind News
Google DeepMind News
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
T
The Blog of Author Tim Ferriss
博客园 - 叶小钗
N
Netflix TechBlog - Medium
腾讯CDC
C
Check Point Blog
P
Proofpoint News Feed
Engineering at Meta
Engineering at Meta
GbyAI
GbyAI
S
SegmentFault 最新的问题
F
Fortinet All Blogs
美团技术团队
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
博客园 - 司徒正美
F
Full Disclosure
Recorded Future
Recorded Future
D
DataBreaches.Net
博客园 - 【当耐特】
Martin Fowler
Martin Fowler
J
Java Code Geeks
I
InfoQ
Y
Y Combinator Blog
A
About on SuperTechFans
AI
AI
爱范儿
爱范儿
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Forbes - Security
Forbes - Security
W
WeLiveSecurity
M
MIT News - Artificial intelligence
雷峰网
雷峰网
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Simon Willison's Weblog
Simon Willison's Weblog
Schneier on Security
Schneier on Security
The GitHub Blog
The GitHub Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
GRAHAM CLULEY
Know Your Adversary
Know Your Adversary
Latest news
Latest news
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
D
Docker
Recent Commits to openclaw:main
Recent Commits to openclaw:main
量子位
V2EX - 技术
V2EX - 技术
Project Zero
Project Zero

博客园 - 三驾马车

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. 与业务逻辑衔接:直接提供可操作的对象,避免手动解析。