问题描述
如果将NioEventLoopGroup
用作workerGroup
,则通过跟随NioEventLoop
中的处理程序,以连续(单线程)的方式处理ByteToMessageDecoder
处理程序(用于单个连接)之后的消息.
If a NioEventLoopGroup
is used as a workerGroup
, messages after ByteToMessageDecoder
handler (for a single connection) are processed in a sequential (single threaded) way by following handlers within NioEventLoop
.
是否可以使它们由ByteToMessageDecoder
处理程序之后的其他工人"处理?
Is it possible to make them to be processed by another «workers» after ByteToMessageDecoder
handler?
推荐答案
是的,只需将带有特殊EventExecutorGroup
的ChannelHandler
添加到ChannelPipeline
.例如 UnorderedThreadPoolEventExecutor ( src ).
Yes, just add a ChannelHandler
with a special EventExecutorGroup
to the ChannelPipeline
. For example UnorderedThreadPoolEventExecutor (src).
所以像这样:
UnorderedThreadPoolEventExecutor executorGroup = ...;
pipeline.addLast(executorGroup, new MyChannelHandler());
这篇关于Netty 4. ByteToMessageCodec之后的并行处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!