SimpleChannelInboundHandler channelInactive userEventTriggered channelRead0bootstrap
ChannelInitializer緩存
SpringBeanFactory.net
@Component @PostConstruct @PreDestroynetty
IdleStateHandlercode
HeartbeatDecoder ByteToMessageDecoder事件
@Configuration內存
ChannelRead channelRead0 messageReceivedget
org.jboss.netty.bootstrap.; First, in Netty 3.X the packages were from org.jboss.netty. io.netty.bootstrap.ServerBootstrap; But started Netty 4.X the packeages are from io.netty.*it
Now, if you are using Netty 4.X to read message use the methodio
ChannelRead(ChannelHandleContext ctx, Object msg) { ... } inherited from ChannelInboundHandlerAdapter class. The method:
ByteBuf ByteBuf buf = Unpooled.buffer();
池化buffer Netty4引入了一種高效緩存池(buffer pool),它是結合了 buddy allocation 以及 slab allocation 的 jemalloc 的變體。
減少buffer的頻繁分配及回收致使的GC壓力 減小新建buffer時0值填充產生的內存帶寬消耗 及時回收直接內存(direct buffers) 爲了能夠利用這些特性,用戶都應該使用 ByteBufAllocator 獲取buffer,除非你但願使用非池化buffer:
Netty的核心組件 在本節中我將要討論Netty的主要構件塊: Channel; 回調; Future; 事件和ChannelHandler。 ChannelFutureListener ChannelFuture