我观察到,如果在收到回调后不立即放置处理程序,那么我会松开例如的消息:
Works
new jChannel.ChannelInitializer[jChannel.socket.SocketChannel] {
override def initChannel(ch: jChannel.socket.SocketChannel): Unit = {
ch.pipeline().addLast(new jHttp.HttpServerCodec())
ch.pipeline().addLast(new jHttp.HttpObjectAggregator(64))
ch.pipeline().addLast(new MyCustomRequestHandler)
}
}
无效
new jChannel.ChannelInitializer[jChannel.socket.SocketChannel] {
override def initChannel(ch: jChannel.socket.SocketChannel): Unit = Future { // Async Handling
ch.pipeline().addLast(new jHttp.HttpServerCodec())
ch.pipeline().addLast(new jHttp.HttpObjectAggregator(64))
ch.pipeline().addLast(new MyCustomRequestHandler)
}
}
我应该怎么做才能确保可以异步附加侦听器。
ChannelOption.AUTO_READ
设置为false
,然后将其设置为true
,然后添加所需的处理程序来完成您想做的事情。例如,您可以在引导过程中指定这些选项吗?>