Netty提供的ChannelHandler

记录一下Netty已提供的主要的ChannelHandler,有助于快速开发。
解码

  1. LineBasedFrameDecoder:A decoder that splits the received ByteBufs on line endings.
  2. DelimiterBasedFrameDecoder:A decoder that splits the received ByteBufs by one or more delimiters.
  3. FixedLengthFrameDecoder:A decoder that splits the received ByteBufs by the fixed number of bytes.
  4. LengthFieldBasedFrameDecoder:A decoder that splits the received ByteBufs dynamically by the value of the length field in the message.
  5. ByteToMessageDecoder:抽象类,由于你不可能知道远程节点是否会一次性地发送一个完整 的消息,所以这个类会对入站数据进行缓冲,直到它准备好处理。
  6. MessageToMessageDecoder:

编码

  1. MessageToByteEncoder: 抽象类,继承该类的实现任意类型到ByteBuf的转化,其他事情有该类完成。
  2. MessageToMessageEncoder:抽象类,

超时检测

  1. ReadTimeoutHandler:Raises a ReadTimeoutException when no data was read within a certain period of time. 如果在指定的时间间隔内没有收到任何的入站数据,则抛出一个 Read- TimeoutException 并关闭对应的 Channel。可以通过重写你的 ChannelHandler 中的 exceptionCaught()方法来检测该 Read- TimeoutException
  2. WriteTimeoutHandler:Raises a WriteTimeoutException when no data was written within a certain period of time. 如果在指定的时间间隔内没有任何出站数据写入,则抛出一个 Write- TimeoutException 并关闭对应的 Channel。可以通过重写你的 ChannelHandler 的 exceptionCaught()方法检测该 WriteTimeout- Exception
  3. IdleStateHandler: 当连接空闲时间太长时,将会触发一个 IdleStateEvent 事件。然后, 你可以通过在你的 ChannelInboundHandler 中重写 userEvent- Triggered()方法来处理该 IdleStateEvent 事件

日志:

  1. LoggingHandler:A ChannelHandler that logs all events using a logging framework.

安全:

  1. SslHandler:

支持HTTP、WebSocket

写大数据,FileRegion 零拷贝

序列化:JDK 序列化,JBoss Marshalling ,Protocol Buffers

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,872评论 0 10
  • 这是一个“教育颠覆”的时代,“颠覆”的意思就是:在当代在具体的你的孩子面前,我们的一切作为都可能是“错”的。而且我...
    张放天阅读 477评论 0 0
  • OAuth2.0笔记 角色 一般资源服务器和授权服务器是一个 资源拥有者 客户端应用 资源服务器 授权服务器 客户...
    output阅读 258评论 0 0
  • SharedPreferences共享参数 SharedPreferences是Android系统提供的一个通用的...
    GB_speak阅读 1,878评论 0 5
  • 2018年1月4日 周四 昨天妹妹妹夫去外县参加朋友母亲的葬礼,让我下班后去妹妹照顾爸爸,我欣然接受。妹妹家,我...
    魅力春天阅读 239评论 4 3

友情链接更多精彩内容