I've been looking over at the proxy server example from Netty website:
The example source code handler has a volatile variable
private volatile Channel outboundChannel;
which takes care of the channel that connects to another server for proxy.
This got me to wonder if this is the correct and safe way to implement for multiple connections for proxy.
I would like to allow multiple connections(inbound) to connect to different outbounds, while making sure that every inbound connection is uniquely linked to the outbound channel.
According to my knowledge, Netty generates a new pipeline for each connection. Does this mean a newly generated handler by pipeline factory is uniquely dedicated to the new connection(channel)?
p.s. If I have 1,000 active connections to my Netty server, does this mean there are 1,000 different pipelines?
In this article we're focused on debugging and extending code using Netty so we won't look at them too closely. This is a container for EventLoop objects. Each EventLoop object is exclusively associated with a single Thread. Each Channel is associated with a single EventLoop throughout its lifetime.
Netty allows you to write your own network protocol tailored to your specific requirements, optimizing the traffic flow for your specific situation, without the unnecessary overhead of something like HTTP or FTP.
Netty is a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients. It greatly simplifies and streamlines network programming such as TCP and UDP socket server.
Netty uses an event-driven application paradigm, so the pipeline of the data processing is a chain of events going through handlers. Events and handlers can be related to the inbound and outbound data flow. Inbound events can be the following: Channel activation and deactivation.
There is one pipeline created per connection, but the pipeline may contain both shared and exclusive handlers. Some handlers do not keep state and a single instance can be inserted into multiple [all] pipelines. Netty provided handlers that can be shared are annotated with ChannelHandler.Sharable. See the section titled Shared and Exclusive Channel Handlers in this tutorial.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With