Netty 4. Parallel processing after ByteToMessageCo

2019-07-15 00:59发布

问题:

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.

Is it possible to make them to be processed by another «workers» after ByteToMessageDecoder handler?

回答1:

Yes, just add a ChannelHandler with a special EventExecutorGroup to the ChannelPipeline. For example UnorderedThreadPoolEventExecutor (src).

So something like:

UnorderedThreadPoolEventExecutor executorGroup = ...;
pipeline.addLast(executorGroup, new MyChannelHandler());


标签: netty