Several points of Netty

Source: Internet
Author: User

    • Netty is the framework of a transport layer, the main function is two: encapsulated the operation of NIO, encapsulated the codec interface, so that NIO developers only need to focus on the business function itself Channelhandler.

    • Not just Netty, the main problem of the transport layer is that these two, processing IO, processing codec

    • Codec mainly deal with the problem is the byte stream sub-frame (frame), generally have the following several
    1. Press the Terminator, such as HTTP
    2. Fixed length
    3. Using the body of the message header, specify the length in the message header, such as TCP, Thrift
    • The front end of the Netty implements multithreaded reactor mode, which allows you to specify the thread pool that the accept handles and the IO read-write thread pool, which is managed by the Netty framework to manage the distribution and thread pooling of events.

    • Netty uses the responsibility chain channelpipeline to manage Channelhandler. Each node in this chain of responsibility can choose which events to focus on to trigger, and the order of the nodes is important. Netty abstracts the concept of inbound and outbound events, the events emitted by the underlying IO to the user layer are called inbound events, and events are passed from pipeline Headhandler to Tailhandler. Events that are emitted by the user layer to the underlying IO, such as write, are Outbond events, passing from Tailhandler to Headhandler, calling unsafe to complete the network operation. So it is important to understand inbound and outbound events when using Netty. The latest netty-5.0 cancels the Inbound/outbound Handler interface, using facade mode design Channelhandler, which contains all inbound and outbound events. The use of adapter mode with Channelhandleradapter empty implementation of Channelhandler, the specific channelhandler only need to inherit channelhandleradapter.

    • Xxxxencoder is used by the user to write to the underlying IO and encodes the business data into a byte stream, so xxxencoder overwrites the Channelhandleradapter write method, responding to the outbound event

    • Xxxxdecoder is used by the underlying IO to send IO events to the user layer, encode the byte stream into business data, or convert the byte stream into a bytebuf, then convert the BYTEBUF into business data and respond to inbound events

Several points of Netty

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.