源码
栗子
ch.pipeline().addLast(new InboundHandler1());
ch.pipeline().addLast(new InboundHandler2());
ch.pipeline().addLast(new OutboundHandler1());
ch.pipeline().addLast(new OutboundHandler2());
链表中的顺序为head->in1->in2->out1->out2->tail
输出:
InboundHandler1
InboundHandler2
OutboundHandler2
OutboundHandler1
一次请求过来,先read,再write,根据顺序
read : in1 in2
write: out2 out1
所以最后的顺序就是 in1 in2 out 2 out1
拾遗
由head开始的往下传播的事件
fireChannelActive
fireChannelInactive
fireExceptionCaught
fireChannelRead
fireChannelReadComplete
…等等
由tail开始的往上传播的事件
bind
connect
write
flush
…等等
InboundHandler关心的事件:
MASK_EXCEPTION_CAUGHT
MASK_CHANNEL_REGISTERED
MASK_CHANNEL_ACTIVE
MASK_CHANNEL_READ
MASK_CHANNEL_READ_COMPLETE
…等等
OutboundHanlder关心的事件:
MASK_EXCEPTION_CAUGHT
MASK_BIND
MASK_CLOSE
MASK_READ
MASK_WRITE
MASK_FLUSH
…等等
参考:
https://blog.csdn.net/zhengchao1991/article/details/103583766
https://blog.csdn.net/qq_41737716/article/details/94734196
https://blog.csdn.net/zhengchao1991/article/details/103583766