Netty Concepts: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 6: Line 6:


=Overview=
=Overview=
Java offers access to network via APIs which historically evolved from blocking to non-blocking. The APIs are quite different. Netty layers in top of these APIs and exposes a common API regardless of whether the interaction with the network layer is performed in a blocking or non-blocking (preferred) fashion.


High throughput non-blocking I/O. Servers and clients. Channel. ChannelPipeline that holds ChannelHandler instances. ChannelHandler is important because it represents the interface between networking concerns and application business logic. Events. Everything is an event (accept new connection, read data, write data - in this context data is an event). Event lifecycle. Events are processed by EventLoops.
High throughput non-blocking I/O. Servers and clients. Channel. ChannelPipeline that holds ChannelHandler instances. ChannelHandler is important because it represents the interface between networking concerns and application business logic. Events. Everything is an event (accept new connection, read data, write data - in this context data is an event). Event lifecycle. Events are processed by EventLoops.
Line 18: Line 22:


"Server" and "client" denote behaviors relative to the network: a "server" binds to a local port and listens for incoming connections, whereas a "client" initiates a network connection to a remote (over the network) process.
"Server" and "client" denote behaviors relative to the network: a "server" binds to a local port and listens for incoming connections, whereas a "client" initiates a network connection to a remote (over the network) process.
Netty exposes a common API regardless of whether the interaction with the network layer is performed in a blocking or non-blocking (preferred) fashion.

Revision as of 22:21, 15 September 2020

Internal

Overview

Java offers access to network via APIs which historically evolved from blocking to non-blocking. The APIs are quite different. Netty layers in top of these APIs and exposes a common API regardless of whether the interaction with the network layer is performed in a blocking or non-blocking (preferred) fashion.


High throughput non-blocking I/O. Servers and clients. Channel. ChannelPipeline that holds ChannelHandler instances. ChannelHandler is important because it represents the interface between networking concerns and application business logic. Events. Everything is an event (accept new connection, read data, write data - in this context data is an event). Event lifecycle. Events are processed by EventLoops.

Transport and NIO Transport.

Both the server and the client go through a bootstrapping process. This is where the business logic (ChannelHandlers) is "deployed".

Netty is both a framework and a class library.

The ChannelHandlerContext represents the binding between the ChannelPipeline and its installed handlers.

"Server" and "client" denote behaviors relative to the network: a "server" binds to a local port and listens for incoming connections, whereas a "client" initiates a network connection to a remote (over the network) process.