Is a Netty handler unique to each connection?

I was looking at a proxy server example from the Netty website :

An example source code handler has a mutable variable.

private volatile Channel outboundChannel;

which takes care of a channel that connects to another proxy server.

This made me wonder if this is the correct and safe implementation method for multiple proxy connections.

I would like to allow several connections (incoming) to connect to different outgoing messages, with each incoming connection being uniquely connected to the outgoing channel.

To my knowledge, Netty creates a new pipeline for each connection. Does this mean that the newly created factory pipeline handler is uniquely dedicated to the new connection (channel)?

ps If I have 1000 active connections to my Netty server, does this mean that there are 1000 different pipelines?

+5
source share
1 answer

One conveyor is created for each conveyor, but the conveyor can contain both general and exclusive handlers. Some handlers do not preserve state, and one instance can be inserted into several [all] pipelines. Netty-provided handlers that can be shared are annotated using ChannelHandler.Sharable . See the section General and exclusive channel handlers in the tutorial .

+8
source

All Articles