[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"site-config":3,"primary-menu":20,"cat-netty":99,"catposts-netty":112,"post-detail-post-netty-pipeline-7fcc13c5":221},{"config":4,"socialLinks":19},{"title":5,"subtitle":6,"logoUrl":7,"faviconUrl":8,"footerText":9,"beianIcp":10,"beianPublicSecurity":9,"seoDescription":11,"seoKeywords":12,"homepageTitle":13,"homepageSubtitle":14,"analyticsHeadCode":15,"planetQrcodeUrl":16,"planetIntroHtml":9,"planetCtaText":17,"updatedAt":18},"编码世界","用编码改变世界","\u002Fupload\u002F2026\u002F09\u002F2f277021172f43f6bb34e1c115760b7f.png","\u002Fupload\u002F2026\u002F09\u002Fdcbad022e68c4a729a5dc4997a9bba8a.png","","苏ICP备2026073884号","编码世界（mashangan.com）是面向 Java 后端与 Go 语言的系统化编程教程站：提供\nMyBatis Plus、Lombok、Java 8、IDEA、Docker 等原创图文教程，以及 JVM、并发、\nSpring、MySQL、Redis、消息队列、计算机网络等大厂面试八股题库，另有可落地的\n项目实战系列，帮你从入门到精通。","编码世界,Java教程,Go语言教程,Docker教程,MyBatis Plus教程,Lombok教程, Java 8新特性,IDEA教程,Java面试题,八股文,JVM面试题,Java并发面试题, MySQL面试题,Redis面试题,Spring面试题,消息队列面试题,高并发,分库分表, Netty面试题,计算机网络面试题,AI Agent,RAG,程序员学习路线","Java全栈系统化编程教程","覆盖 MyBatis Plus、Lombok、Java 8、IDEA、Go、Docker 等原创图文教程，配套大厂面试八股题库，从入门到精通，持续更新","\u003Cscript>\nvar _hmt = _hmt || [];\n(function() {\n  var hm = document.createElement(\"script\");\n  hm.src = \"https:\u002F\u002Fhm.baidu.com\u002Fhm.js?f00af7e56d956c02e11efed4131379b0\";\n  var s = document.getElementsByTagName(\"script\")[0]; \n  s.parentNode.insertBefore(hm, s);\n})();\n\u003C\u002Fscript>\n","\u002Fupload\u002F2026\u002F09\u002Fc1a8f5de46584d3eb0bc762c180a5db9.png","扫码加入知识星球","2026-09-29T14:56:02.498693Z",[],{"metadata":21,"spec":24,"menuItems":34},{"name":22,"creationTimestamp":23},"primary","2026-09-12T06:13:55.024154Z",{"displayName":25,"menuItems":26},"主菜单",[27,28,29,30,31,32,33],"88c3f10b-321c-4092-86a8-70db00251b74","menu-item-izrtmxer","c4c814d1-0c2c-456b-8c96-4864965fee94","menu-item-column","menu-item-tools","menu-item-zsxq","menu-item-ocrxlczu",[35,44,54,63,72,81,90],{"displayName":36,"metadata":37,"spec":39,"status":42,"children":43},"首页",{"name":27,"creationTimestamp":38},"2026-09-12T06:13:54.422830Z",{"displayName":36,"href":40,"priority":41,"menuName":22},"\u002F",0,{"displayName":36,"href":40},[],{"displayName":45,"metadata":46,"spec":48,"status":52,"children":53},"Java面试八股",{"name":28,"creationTimestamp":47},"2026-09-13T09:42:02.854891Z",{"displayName":45,"href":49,"target":50,"priority":51,"menuName":22},"\u002Fjava-interview","_self",1,{"displayName":45,"href":49},[],{"displayName":55,"metadata":56,"spec":58,"status":61,"children":62},"文章",{"name":29,"creationTimestamp":57},"2026-09-12T06:13:54.457307Z",{"displayName":55,"href":59,"priority":60,"menuName":22},"\u002Farchives",2,{"displayName":55,"href":59},[],{"displayName":64,"metadata":65,"spec":67,"status":70,"children":71},"项目实战",{"name":30,"creationTimestamp":66},"2026-09-14T00:35:08.138170Z",{"displayName":64,"href":68,"target":50,"priority":69,"menuName":22},"\u002Fcolumn",3,{"displayName":64,"href":68},[],{"displayName":73,"metadata":74,"spec":76,"status":79,"children":80},"在线工具",{"name":31,"creationTimestamp":75},"2026-09-14T00:35:08.171474Z",{"displayName":73,"href":77,"target":50,"priority":78,"menuName":22},"\u002Ftools",4,{"displayName":73,"href":77},[],{"displayName":82,"metadata":83,"spec":85,"status":88,"children":89},"知识星球",{"name":32,"creationTimestamp":84},"2026-09-14T00:35:08.199145Z",{"displayName":82,"href":86,"target":50,"priority":87,"menuName":22},"\u002Fzsxq",5,{"displayName":82,"href":86},[],{"displayName":91,"metadata":92,"spec":94,"status":97,"children":98},"特价云服务器",{"name":33,"creationTimestamp":93},"2026-09-25T15:30:59.201614Z",{"displayName":91,"href":95,"target":50,"priority":96,"menuName":22},"\u002Fserver",6,{"displayName":91,"href":95},[],{"metadata":100,"spec":105,"status":110,"postCount":87},{"name":101,"creationTimestamp":102,"labels":103},"netty","2026-09-13T09:13:25.996566Z",{"haloweb.section":104},"interview",{"displayName":106,"slug":101,"cover":9,"description":107,"priority":108,"hideFromList":109,"preventParentPostCascadeQuery":109},"Netty 面试题","Netty 面试题：Reactor 线程模型、ByteBuf、零拷贝、编解码与常见内存泄漏排查。",29,false,{"permalink":111,"postCount":87,"visiblePostCount":87},"\u002Fcategories\u002Fnetty",[113,137,158,179,200],{"metadata":114,"spec":117,"status":126,"categories":131},{"name":115,"creationTimestamp":116},"post-netty-heartbeat-12b221d2","2026-09-13T10:01:12.589477Z",{"title":118,"slug":119,"cover":9,"excerpt":120,"publishTime":122,"categories":123,"tags":124,"priority":41,"pinned":109,"deleted":109,"visible":125,"allowComment":121},"Netty 如何实现心跳检测？","netty-heartbeat",{"raw":9,"autoGenerate":121},true,"2026-09-13T10:01:12.638155Z",[101],[],"PUBLIC",{"permalink":127,"excerpt":128,"lastModifyTime":129,"phase":130},"\u002Farchives\u002Fnetty-heartbeat","一、IdleStateHandler Netty 提供 IdleStateHandler 检测空闲状态。 ch.pipeline().addLast(new IdleStateHandler(5, 0, 0, TimeUnit.SECONDS));\n 三个参数：读空闲时间、写空闲时间、所有空闲时间。","2026-09-16T09:16:11.001714Z","PUBLISHED",[132],{"metadata":133,"spec":135,"status":136,"postCount":87},{"name":101,"creationTimestamp":102,"labels":134},{"haloweb.section":104},{"displayName":106,"slug":101,"cover":9,"description":107,"priority":108,"hideFromList":109,"preventParentPostCascadeQuery":109},{"permalink":111,"postCount":87,"visiblePostCount":87},{"metadata":138,"spec":141,"status":148,"categories":152},{"name":139,"creationTimestamp":140},"post-netty-sticky-packet-db78caff","2026-09-13T10:01:12.394145Z",{"title":142,"slug":143,"cover":9,"excerpt":144,"publishTime":145,"categories":146,"tags":147,"priority":41,"pinned":109,"deleted":109,"visible":125,"allowComment":121},"Netty 如何解决粘包拆包？","netty-sticky-packet",{"raw":9,"autoGenerate":121},"2026-09-13T10:01:12.445874Z",[101],[],{"permalink":149,"excerpt":150,"lastModifyTime":151,"phase":130},"\u002Farchives\u002Fnetty-sticky-packet","一、问题 TCP 是字节流，没有消息边界，多个请求可能粘在一起（粘包），一个请求可能被拆分（拆包）。 二、解决方案 固定长度：FixedLengthFrameDecoder，每条消息固定长度。 特殊分隔符：DelimiterBasedFrameDecoder，按换行符等分隔。 长度字段：Length","2026-09-16T09:16:10.566524Z",[153],{"metadata":154,"spec":156,"status":157,"postCount":87},{"name":101,"creationTimestamp":102,"labels":155},{"haloweb.section":104},{"displayName":106,"slug":101,"cover":9,"description":107,"priority":108,"hideFromList":109,"preventParentPostCascadeQuery":109},{"permalink":111,"postCount":87,"visiblePostCount":87},{"metadata":159,"spec":162,"status":169,"categories":173},{"name":160,"creationTimestamp":161},"post-netty-bytebuf-9e659725","2026-09-13T10:01:12.219331Z",{"title":163,"slug":164,"cover":9,"excerpt":165,"publishTime":166,"categories":167,"tags":168,"priority":41,"pinned":109,"deleted":109,"visible":125,"allowComment":121},"Netty 的 ByteBuf 设计？","netty-bytebuf",{"raw":9,"autoGenerate":121},"2026-09-13T10:01:12.269412Z",[101],[],{"permalink":170,"excerpt":171,"lastModifyTime":172,"phase":130},"\u002Farchives\u002Fnetty-bytebuf","一、与 ByteBuffer 对比 JDK ByteBuffer 只有一个 position，读写切换需 flip()，易出错。 ByteBuf 有 readerIndex 和 writerIndex 两个指针，读写分离，无需 flip。 二、核心方法 readXxx() \u002F writeXxx()：","2026-09-16T09:15:44.072779Z",[174],{"metadata":175,"spec":177,"status":178,"postCount":87},{"name":101,"creationTimestamp":102,"labels":176},{"haloweb.section":104},{"displayName":106,"slug":101,"cover":9,"description":107,"priority":108,"hideFromList":109,"preventParentPostCascadeQuery":109},{"permalink":111,"postCount":87,"visiblePostCount":87},{"metadata":180,"spec":183,"status":190,"categories":194},{"name":181,"creationTimestamp":182},"post-netty-pipeline-7fcc13c5","2026-09-13T10:01:12.057563Z",{"title":184,"slug":185,"cover":9,"excerpt":186,"publishTime":187,"categories":188,"tags":189,"priority":41,"pinned":109,"deleted":109,"visible":125,"allowComment":121},"Netty 的 ChannelPipeline 机制？","netty-pipeline",{"raw":9,"autoGenerate":121},"2026-09-13T10:01:12.104621Z",[101],[],{"permalink":191,"excerpt":192,"lastModifyTime":193,"phase":130},"\u002Farchives\u002Fnetty-pipeline","一、定义 每个 Channel 有一个 Pipeline，由多个 ChannelHandler 组成，形成责任链。入站和出站事件在 Pipeline 中传播。 二、入站和出站 InboundHandler：处理入站事件（读、连接建立等），从 head 向 tail 传播。 OutboundHandl","2026-09-16T09:16:10.087911Z",[195],{"metadata":196,"spec":198,"status":199,"postCount":87},{"name":101,"creationTimestamp":102,"labels":197},{"haloweb.section":104},{"displayName":106,"slug":101,"cover":9,"description":107,"priority":108,"hideFromList":109,"preventParentPostCascadeQuery":109},{"permalink":111,"postCount":87,"visiblePostCount":87},{"metadata":201,"spec":204,"status":211,"categories":215},{"name":202,"creationTimestamp":203},"post-netty-reactor-452c619b","2026-09-13T10:01:11.735905Z",{"title":205,"slug":206,"cover":9,"excerpt":207,"publishTime":208,"categories":209,"tags":210,"priority":41,"pinned":109,"deleted":109,"visible":125,"allowComment":121},"Netty 的 Reactor 线程模型？","netty-reactor",{"raw":9,"autoGenerate":121},"2026-09-13T10:01:11.908097Z",[101],[],{"permalink":212,"excerpt":213,"lastModifyTime":214,"phase":130},"\u002Farchives\u002Fnetty-reactor","一、Reactor 模式 基于事件驱动，I\u002FO 多路复用监听多个连接，事件就绪后分发给处理器。 二、Netty 三种模型 单线程 Reactor：一个线程处理所有连接的 accept 和 I\u002FO，简单但不适合高并发。 多线程 Reactor：一个 Acceptor 线程接收连接，I\u002FO 由线程池处理","2026-09-16T09:15:45.558022Z",[216],{"metadata":217,"spec":219,"status":220,"postCount":87},{"name":101,"creationTimestamp":102,"labels":218},{"haloweb.section":104},{"displayName":106,"slug":101,"cover":9,"description":107,"priority":108,"hideFromList":109,"preventParentPostCascadeQuery":109},{"permalink":111,"postCount":87,"visiblePostCount":87},{"metadata":222,"spec":223,"status":227,"categories":228,"content":234},{"name":181,"creationTimestamp":182},{"title":184,"slug":185,"cover":9,"excerpt":224,"publishTime":187,"categories":225,"tags":226,"priority":41,"pinned":109,"deleted":109,"visible":125,"allowComment":121},{"raw":9,"autoGenerate":121},[101],[],{"permalink":191,"excerpt":192,"lastModifyTime":193,"phase":130},[229],{"metadata":230,"spec":232,"status":233,"postCount":87},{"name":101,"creationTimestamp":102,"labels":231},{"haloweb.section":104},{"displayName":106,"slug":101,"cover":9,"description":107,"priority":108,"hideFromList":109,"preventParentPostCascadeQuery":109},{"permalink":111,"postCount":87,"visiblePostCount":87},{"content":235,"raw":235},"\u003Ch2>一、定义\u003C\u002Fh2>\n\u003Cp>每个 Channel 有一个 Pipeline，由多个 ChannelHandler 组成，形成责任链。入站和出站事件在 Pipeline 中传播。\u003C\u002Fp>\n\u003Ch2>二、入站和出站\u003C\u002Fh2>\n\u003Cul>\n\u003Cli>\u003Cstrong>InboundHandler\u003C\u002Fstrong>：处理入站事件（读、连接建立等），从 head 向 tail 传播。\u003C\u002Fli>\n\u003Cli>\u003Cstrong>OutboundHandler\u003C\u002Fstrong>：处理出站事件（写、连接等），从 tail 向 head 传播。\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Ch2>三、常用 Handler\u003C\u002Fh2>\n\u003Cul>\n\u003Cli>ByteToMessageDecoder：字节解码为消息。\u003C\u002Fli>\n\u003Cli>MessageToByteEncoder：消息编码为字节。\u003C\u002Fli>\n\u003Cli>IdleStateHandler：心跳检测。\u003C\u002Fli>\n\u003Cli>LoggingHandler：日志。\u003C\u002Fli>\n\u003Cli>自定义业务 Handler。\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Ch2>四、示例\u003C\u002Fh2>\n\u003Cpre>\u003Ccode class=\"language-java\">ch.pipeline()\n  .addLast(new LengthFieldBasedFrameDecoder(...))\n  .addLast(new MyDecoder())\n  .addLast(new MyEncoder())\n  .addLast(new BusinessHandler());\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2>五、注意\u003C\u002Fh2>\n\u003Cul>\n\u003Cli>Handler 处理耗时操作应放到业务线程池，避免阻塞 EventLoop。\u003C\u002Fli>\n\u003Cli>Handler 加 @Sharable 注解可共享，否则每次新建。\u003C\u002Fli>\n\u003C\u002Ful>"]