Netty
Netty is a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients.
Netty project - an event-driven asynchronous network application framework
初步认识
Netty5 为何被废弃?
why github do not have netty5 branch?
After talking with @Scottmitch and also with @nmittler I would like to propose "dropping" current master and so not release any new 5.0 version for now.
The major change of using a ForkJoinPool increases complexity and has not
demonstrated a clear performance benefit. Also keeping all the branches in sync is quite some work without a real need for it as there is nothin in current master which I think justifies a new major release.
Things that we should investigate to prepare for this change:
1. Deprecate exceptionCaught in ChannelHandler, only expose it in ChannelInboundHandler
2. Expose EventExecutorChooser from MultithreadEventExecutorGroup to allow the user more flexibility to choose next EventLoop
3. Add another method to be able to send user events both ways in the pipeline. (#4378)
Please chime in here and let me / us hear any concerns.
代码案例
<!-- https://mvnrepository.com/artifact/io.netty/netty-all -->
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.68.Final</version>
</dependency>
github.com/morningcat2018/netty-sample-lecture
使用 Netty 不使用 JDK 原生 NIO 的原因
- 使用 JDK 自带的NIO需要了解太多的概念,编程复杂,一不小心 bug 横飞
- Netty 底层 IO 模型随意切换,而这一切只需要做微小的改动,改改参数,Netty可以直接从 NIO 模型变身为 IO 模型
- Netty 自带的拆包解包,异常检测等机制让你从NIO的繁重细节中脱离出来,让你只需要关心业务逻辑
- Netty 解决了 JDK 的很多包括空轮询在内的 Bug
- Netty 底层对线程,selector 做了很多细小的优化,精心设计的 reactor 线程模型做到非常高效的并发处理
- 自带各种协议栈让你处理任何一种通用协议都几乎不用亲自动手
- Netty 社区活跃,遇到问题随时邮件列表或者 issue
- Netty 已经历各大 RPC 框架,消息中间件,分布式通信中间件线上的广泛验证,健壮性无比强大
– https://juejin.cn/book/6844733738119593991/section/6844733738270588942