This is only possible if you have added one of the ChannelHandler to the pipeline with a EventExecutorGroup passed in. If you not use one everything will just handled by the EventLoop and so one Thread.
Are concurrent reads possible in Netty 4?
-
12-07-2023 - |
Question
From these notes:
Netty will never call a
ChannelHandler
's methods concurrently, unless theChannelHandler
is annotated with@Sharable
. This is regardless of the type of handler methods - inbound, outbound, or life cycle event handler methods.
I have no problem with that. My question is, however, if it is possible for two different messages to be read/processed from the same channel at the same time, at different stages of the pipeline.
For instance, consider the following pipeline (ChannelInboundHandler
s only):
+-----------+ | Handler 2 | +-----------+ ^ | +-----------+ | Handler 1 | +-----------+ ^ | +-----------+ | I/O read | +-----------+
I understand that only one thread, at most, may be calling the methods from Handler 1
, unless it is Sharable
. But, can a thread be processing a message in Handler 2
while another thread is processing a message for the same channel in Handler 1
? Or is the channel selected only when the current message reaches the end of the pipeline?
La solution