我想实施一个网络"奴隶"侦听传出 websocket连接上的请求的应用程序。所以在bootstrap上,应用程序会:
我的问题是如何提升频道 - 为了方便起见,我宁愿使用引导对象(我的意思是手动配置频道),但是:
有关如何在不复制大量现有* Bootstrap代码的情况下引导通道的任何建议吗?
答案 0 :(得分:0)
我最终通过ChannelPipeline.html.addLast()将EventExecutorGroup直接传递给管道 - 我在api文档中错过了这个。
来自javadocs:
static final EventExecutorGroup group = new DefaultEventExecutorGroup(16);
...
ChannelPipeline pipeline = ch.pipeline();
pipeline.addLast("decoder", new MyProtocolDecoder());
pipeline.addLast("encoder", new MyProtocolEncoder());
// Tell the pipeline to run MyBusinessLogicHandler's event handler methods
// in a different thread than an I/O thread so that the I/O thread is not blocked by
// a time-consuming task.
// If your business logic is fully asynchronous or finished very quickly, you don't
// need to specify a group.
pipeline.addLast(group, "handler", new MyBusinessLogicHandler());