本文介绍了Netty 4. ByteToMessageCodec之后的并行处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果将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?

推荐答案

是的,只需将带有特殊EventExecutorGroupChannelHandler添加到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之后的并行处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 16:01