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

推荐订阅源

V
Vulnerabilities – Threatpost
U
Unit 42
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
P
Proofpoint News Feed
F
Full Disclosure
月光博客
月光博客
Engineering at Meta
Engineering at Meta
博客园_首页
The Register - Security
The Register - Security
G
Google Developers Blog
The Cloudflare Blog
博客园 - Franky
K
Kaspersky official blog
A
Arctic Wolf
Scott Helme
Scott Helme
C
Cisco Blogs
Hugging Face - Blog
Hugging Face - Blog
C
Check Point Blog
NISL@THU
NISL@THU
AI
AI
D
DataBreaches.Net
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Stack Overflow Blog
Stack Overflow Blog
Project Zero
Project Zero
The GitHub Blog
The GitHub Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
量子位
Vercel News
Vercel News
T
Tor Project blog
P
Privacy International News Feed
D
Docker
I
Intezer
L
LangChain Blog
P
Proofpoint News Feed
Security Latest
Security Latest
C
CXSECURITY Database RSS Feed - CXSecurity.com
T
Threatpost
博客园 - 聂微东
AWS News Blog
AWS News Blog
Martin Fowler
Martin Fowler
P
Privacy & Cybersecurity Law Blog
V
V2EX
Last Week in AI
Last Week in AI
C
Cybersecurity and Infrastructure Security Agency CISA
The Hacker News
The Hacker News
T
Tenable Blog
Blog — PlanetScale
Blog — PlanetScale
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog

博客园 - 三驾马车

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