---
title: "MINA使用札记（CumulativeProtocolDecoder使用）"
author: "javaeye_hua"
date: "2013-04-19T14:57:44Z"
tags: []
categories: ["企业架构"]
slug: "mina-cumulativeprotocoldecoder"
draft: false
lastmod: "2013-04-19T15:19:45Z"
id: 1850205
url: "https://javaeye-hua.iteye.com/blog/1850205"
---

1\. filter中，调用out.write(data)，进行后续过滤器链、handler处理器操作

2\. CumulativeProtocolDecoder的doDecoder中，

return false，将IoBuffer中未读取数据方如IoSession缓存中，待下次数据上报时，合并一起提交。

    每次都是将当前IoBuffer中剩余数据放入IoSession缓存，与下一次上报IoBuffer中数据合并

return true,IoBuffer中必须全部读取（position==limit），否则会抛出异常。同时，编码器自动清空缓存。

下次数据接收，IoBuffer中数据position从0开始放入数据

3\. out.write(data)，每次write操作，都会触发后续过滤器链、handler处理器等一些列操作