Class FlowControlHandler

  • All Implemented Interfaces:
    io.netty5.channel.ChannelHandler

    public class FlowControlHandler
    extends Object
    implements io.netty5.channel.ChannelHandler
    The FlowControlHandler ensures that only one message per read() is sent downstream. Classes such as ByteToMessageDecoder or MessageToByteEncoder are free to emit as many events as they like for any given input. A channel's auto reading configuration doesn't usually apply in these scenarios. This is causing problems in downstream ChannelHandlers that would like to hold subsequent events while they're processing one event. It's a common problem with the HttpObjectDecoder that will very often fire an HttpRequest that is immediately followed by a LastHttpContent event.
    {@code
     ChannelPipeline pipeline = ...;
    
     pipeline.addLast(new HttpServerCodec());
     pipeline.addLast(new FlowControlHandler());
    
     pipeline.addLast(new MyExampleHandler());
    
     class MyExampleHandler extends ChannelInboundHandlerAdapter {
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void channelInactive​(io.netty5.channel.ChannelHandlerContext ctx)  
      void channelRead​(io.netty5.channel.ChannelHandlerContext ctx, Object msg)  
      void channelReadComplete​(io.netty5.channel.ChannelHandlerContext ctx)  
      void handlerRemoved​(io.netty5.channel.ChannelHandlerContext ctx)  
      void read​(io.netty5.channel.ChannelHandlerContext ctx, io.netty5.channel.ReadBufferAllocator readBufferAllocator)  
      • Methods inherited from interface io.netty5.channel.ChannelHandler

        bind, channelActive, channelExceptionCaught, channelInboundEvent, channelRegistered, channelShutdown, channelUnregistered, channelWritabilityChanged, close, connect, deregister, disconnect, flush, handlerAdded, isSharable, pendingOutboundBytes, register, sendOutboundEvent, shutdown, write
    • Constructor Detail

      • FlowControlHandler

        public FlowControlHandler()
      • FlowControlHandler

        public FlowControlHandler​(boolean releaseMessages)
    • Method Detail

      • handlerRemoved

        public void handlerRemoved​(io.netty5.channel.ChannelHandlerContext ctx)
                            throws Exception
        Specified by:
        handlerRemoved in interface io.netty5.channel.ChannelHandler
        Throws:
        Exception
      • channelInactive

        public void channelInactive​(io.netty5.channel.ChannelHandlerContext ctx)
                             throws Exception
        Specified by:
        channelInactive in interface io.netty5.channel.ChannelHandler
        Throws:
        Exception
      • read

        public void read​(io.netty5.channel.ChannelHandlerContext ctx,
                         io.netty5.channel.ReadBufferAllocator readBufferAllocator)
        Specified by:
        read in interface io.netty5.channel.ChannelHandler
      • channelRead

        public void channelRead​(io.netty5.channel.ChannelHandlerContext ctx,
                                Object msg)
                         throws Exception
        Specified by:
        channelRead in interface io.netty5.channel.ChannelHandler
        Throws:
        Exception
      • channelReadComplete

        public void channelReadComplete​(io.netty5.channel.ChannelHandlerContext ctx)
                                 throws Exception
        Specified by:
        channelReadComplete in interface io.netty5.channel.ChannelHandler
        Throws:
        Exception