The first step of the first Netty application
- Service side (Serverchannel)
- Echoserverhandler simple receive print, return the received message to the sender
- Flushes all pending messages to the remote node
- After closing the channel, the operation is completed
- Service-side (server)
- Echoserver creating Eventloopgroup, Serverbootstrap
- Specify Channel
- Set the socket address to use the selected port
- Add Echoserverhandler to Channel channelpipeline
- Bind server; Sync waits for server to close
- Close the channel and block until it is closed
- Shut down the Eventloopgroup, release all resources
- Build process for client , Bootstrap
The second step is familiar with components
- The learning steps are as follows:
- Channel, Channelhandler
- Encode, Decode, Bytebuf
- Channelhandlercontext
- Referencecountutil
- Channelfuture, Promise
- Channelpipeline, Channelinitializer
- EventLoop, Eventloopgroup
- Attributekey
Charsetutil
As far as possible, according to its correspondence in the entire communication process of the CIS, explain all Netty main components. The approximate structure diagram is as follows:
1.Channel, Channelhandler
Be familiar with the usefulness of each method within the Channelinboundhandleradapter abstract class.
Using the single principle of responsibility, the message
2.Encode, Decode, Bytebuf
The third step is difficult and important
- EventLoop number, Name
- Sticky bag, half bag
- Heartbeat 3 times
- reconnects
- Session
- Don't want to go to keywords
- Memory protection, overflow oom
- Number of connections and release
- Deny connection, blacklist, whitelist
- Nginx
- Fail over retry and idempotent
Fourth Step High-order principle
- Bytebuf
- Channel and unsafe
- Channelpipeline and Channelhandler
- EventLoop and Eventloopgroup
- Future and promise
Netty Learning Route Planning