Netty shutting down the client

Source: Internet
Author: User

When you start the client, we generally

Channelfuture.channel (). Closefuture (). sync ();

This is a block of code, unless the link is broken, otherwise it will not be terminated, we can manually shut down in the handler, to achieve the effect of shutting down the client

 Packageorg.zln.netty.five.part05.client;ImportIo.netty.channel.ChannelHandlerAdapter;ImportIo.netty.channel.ChannelHandlerContext;ImportOrg.slf4j.Logger;Importorg.slf4j.LoggerFactory;ImportOrg.zln.netty.five.part05.dto.SubscribeReq;ImportOrg.zln.netty.five.part05.dto.SubscribeResp;/*** Created by Sherry on 16/11/5.*/ Public classSubreqclienthandlerextendsChannelhandleradapter {/*** Log*/    PrivateLogger Logger = Loggerfactory.getlogger (Subreqclienthandler.class); Private Static intCount = 0;    。。。。。。 @Override Public voidChannelread (Channelhandlercontext ctx, Object msg)throwsException {subscriberesp subscriberesp=(SUBSCRIBERESP) msg; Logger.debug ("This is the received first" + (++count) + "pen response--" +Subscriberesp); //Close LinkCtx.close (); }。。。。。。 }

Netty shutting down the client

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.