是个inbound handler,channelRead方法里面,用一个bytebuf(cumulation)来把下一个数据包和当前这一个拼在一起,以免同一个请求被拆包。然后callDecode,里面调用decode这个方法

decode是被子类重写的方法,像rocketMq的NettyDecoder其实主要的逻辑还是在它继承的LengthFieldBasedFrameDecoder中,而LengthFieldBasedFrameDecoder又继承了ByteToMessageDecoder。

所以LengthFieldBasedFrameDecoder就是一种解决粘包的方案:在报文头中用固定长度字段表示当前报文长度。

super(FRAME_MAX_LENGTH, 0, 4, 0, 4);

/**
* Creates a new instance.
*
* @param maxFrameLength-----------最大帧长,Integer.parseInt(System.getProperty("com.rocketmq.remoting.frameMaxLength", "16777216"));
* the maximum length of the frame. If the length of the frame is
* greater than this value, {@link TooLongFrameException} will be
* thrown.
* @param lengthFieldOffset----------描述当前帧长的第一个字节的起始位置,因为有时候信息并不是直接以帧长开头,有可能前面还有别的信息
* the offset of the length field
* @param lengthFieldLength----------描述当前帧长的字节的个数
* the length of the length field
* @param lengthAdjustment----------比如实际帧长是40,描述帧长的字节是4,如果你的lengthFieldLength的值是44(有的人会把描述的数据本身长度也算进去),那么就得有4的调整,才准确
* the compensation value to add to the value of the length field
* @param initialBytesToStrip----------解析时候需要跳过的字节长,这个是干啥?
* the number of first bytes to strip out from the decoded frame
*/

callDecode调用decode传入三个参数: context, bytebuf, out, 第三个out是一个list,里面放的是解决了拆包粘包问题之后解析出来的完整的一个请求,然后for循环发起channelread,RocktMq server的源码里是封装成一个

command对象,然后发起链式的处理

最新文章

  1. 【JUC】JUC集合框架综述
  2. hdu2874 LCA在线算法
  3. 对象转型 casting
  4. 使用Merge Into 语句实现 Insert/Update
  5. ListView 使用详解
  6. Oracle 闪回特性(FLASHBACK DATABASE)
  7. 跟着Android官网学习Activity
  8. HTML5 Canvas核心技术—图形、动画与游戏开发.pdf3
  9. Android 关于 OnScrollListener 事件顺序次数的简要分析
  10. Kmeans算法与KNN算法的区别
  11. 【xsy2140】计数
  12. Web Api 过滤器之 ExceptionFilter 异常过滤器
  13. 构造方法为private与类修饰符为final
  14. 比起Windows,怎样解读Linux的文件系统与目录结构?
  15. python机器学习-sklearn挖掘乳腺癌细胞(四)
  16. 【转】RESTful Webservice创建
  17. Oracle 口令文件:即 oracle密码文件
  18. mysql恢复ibd文件
  19. Testng用例失败重新运行
  20. 停止学习框架(Stop Learning Frameworks)

热门文章

  1. Flask最强攻略 - 跟DragonFire学Flask - 第十五篇 Flask-Script
  2. CSS——对position定位和margin-top的理解
  3. Spring 集成 Swagger UI
  4. hisi 生产固件生成
  5. Docker Swarm redis 集群搭建
  6. inotify+rsync架构实现实时同步
  7. UI自动化(五)dom
  8. webpack搭建项目时出现的报错“Module build failed (from ./node_modules/css-loader/dist/cjs.js) CssSyntaxError”
  9. 详解java中的byte类型
  10. 洛谷 P1273 【有线电视网】