Netty event propagation mechanism

Article Directory


Source

Here Insert Picture Description

Here Insert Picture Description

chestnut

ch.pipeline().addLast(new InboundHandler1());  
ch.pipeline().addLast(new InboundHandler2()); 
ch.pipeline().addLast(new OutboundHandler1());  
ch.pipeline().addLast(new OutboundHandler2());

The order of the list for the head-> in1-> in2-> out1-> out2-> tail

Output:

InboundHandler1 
InboundHandler2 
OutboundHandler2
OutboundHandler1

A request over the first read, then write, according to the order

read : in1 in2
write: out2 out1

So the final order is in1 in2 out 2 out1

Here Insert Picture Description

Here Insert Picture Description

Supplements


Down by the head start of the event spread
fireChannelActive
fireChannelInactive
fireExceptionCaught
fireChannelRead
fireChannelReadComplete
... etc.

By the start of the event tail spread up
the bind
Connect
the Write
flush
... etc.


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
…等等

Published 555 original articles · won praise 4044 · Views 2.84 million +

Guess you like

Origin blog.csdn.net/dataiyangu/article/details/105370323