Netty 3.2.6到Netty 4.0x迁移

时间:2013-09-13 07:10:07

标签: java migration version netty

我有关于迁移的具体问题

a)我目前正在使用IdleStateAwareChannelUpstreamHandler处理channelIdle事件以及其他常规ChannelUpstream事件回调。当这被迁移到4.0x模型时,应该采用同等的方法?

b)4.0x中EventExecutor的等效OrdredMemoryAwareThreadPoolExecutor是什么?

c)在3.2.6中,我使用了来自处理程序回调的事件对象的channelId来唯一地跟踪客户端。例如,在channelConnected回调中,我曾经从channelId获取evt.getChannel().getId()。由于事件在4.0x中更细粒度,获得Netty生成的唯一通道ID的最佳方法是什么?我检查了ChannelHandlerContext是否提供了获取相同的方法。但我找不到相应的

我指的是http://netty.io/4.0/api/

的javadocs

提前致谢

1 个答案:

答案 0 :(得分:2)

a)查看IdleStateHandler的javadoc。您需要在userEventTriggered(..)方法中拦截IdleStateEvents。

b)在向ChannelPipeline添加ChannelHandler时指定EventExecutor。见No more ExecutionHandler - it's in the core.

c)Channel上目前没有id()了。您现在可以使用Channel.hashCode()。很可能id()将在以后的版本中返回。