源碼
栗子
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