MQTT---hivemq source details (v) netty-Startup and listeners loading

Source: Internet
Author: User
Tags addall

Implementation features

Start Netty, follow the user-configured listener to listen for the port, accept the link sent by the client

Implementation steps

1. Start Netty
2, through the Listenerconfigurationservice to obtain the user's listener configuration, the corresponding configuration is bound to Netty.

Class diagram

This UML familiar with Netty's friends should look very clear, down we post a few pieces of code, to see how hivemq is bound.

 PublicListenablefuture<list<listenerstartresult>>startlisteners() {//For Netty registration shutdown, in order to enable the Netty main thread in the shutdown, can shut down the worker and boss         This. Shutdownregistry.register (NewNettyshutdown ( This. Childeventloop, This. Parenteventloop, This. Hivemqconfigurationservice.internalconfiguration (). GetInt (Internals.event_loop_group_shutdown_timeout));//Record the future list of the results of the listener startup to facilitate printing the results of listener bindings in the Log/console. List<listenerstartfuture> startfutures =NewArraylist<> ();//If the user does not configure listener, a binding to 1883 port will be added by default TcpListenerAdddefaultlistenerwhenlistenersisempty ();//obtained from user Configuration to tcplisteners bound to NettyStartfutures.addall (Starttcplisteners ( This. Listenerconfigurationservice.gettcplisteners ()));//obtained from user Configuration to tlstcplisteners bound to NettyStartfutures.addall (Starttlstcplisteners ( This. Listenerconfigurationservice.gettlstcplisteners ()));//obtained from user Configuration to websocketlisteners bound to NettyStartfutures.addall (Startwebsocketlisteners ( This. Listenerconfigurationservice.getwebsocketlisteners ()));//obtained from user Configuration to tlswebsocketlisteners bound to NettyStartfutures.addall (Starttlswebsocketlisteners ( This. Listenerconfigurationservice.gettlswebsocketlisteners ()));//Convert a bunch of startup future into a future that makes the caller (Hivemqserver) easy to use.         returnGetstartresult (Startfutures); }

By the above process can be known, the specific code processing process
1, by Hivemqserver, call Nettyserver start, start Netty.
2. Then call Startlisteners, bind the configured listeners to Netty

MQTT Exchange Group: 221405150

MQTT---hivemq source details (v) netty-Startup and listeners loading

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.