【发布时间】:2015-06-10 14:28:00
【问题描述】:
我正在使用此示例代码创建频道:
EventLoopGroup group = new NioEventLoopGroup();
try {
Bootstrap b = new Bootstrap();
b.group(group)
.channel(NioSocketChannel.class)
.option(ChannelOption.SO_KEEPALIVE, true)
.handler(new ClientInitializer());
// Start the connection attempt.
Channel ch = b.connect(host, port).sync().channel();
所以我在这里获得了一个频道(频道未来),但我的应用程序吞吐量会非常高,所以我认为一个频道是不够的,所以请告诉我如何创建频道池。
我正在使用 netty 4.0
【问题讨论】:
-
这里是一个频道池的例子:stackoverflow.com/questions/15799820/…
-
Netty 4.0.28 现在支持通道池。见netty.io/news/2015/05/07/4-0-28-Final.html
-
频道池对我来说工作正常。我面临的唯一问题是,当服务器回复客户端时,我无法在我的客户端处理程序(扩展 SimpleChannelInboundHandler
)channelRead0 方法中得到它。有什么提示吗?