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