- java.lang.Object
-
- io.netty5.handler.flow.FlowControlHandler
-
- All Implemented Interfaces:
ChannelHandler
public class FlowControlHandler extends Object implements ChannelHandler
TheFlowControlHandler
ensures that only one message perread()
is sent downstream. Classes such asByteToMessageDecoder
orMessageToByteEncoder
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 downstreamChannelHandler
s that would like to hold subsequent events while they're processing one event. It's a common problem with theHttpObjectDecoder
that will very often fire anHttpRequest
that is immediately followed by aLastHttpContent
event.{@code ChannelPipeline pipeline = ...; pipeline.addLast(new HttpServerCodec()); pipeline.addLast(new FlowControlHandler()); pipeline.addLast(new MyExampleHandler()); class MyExampleHandler extends ChannelInboundHandlerAdapter {
-
-
Constructor Summary
Constructors Constructor Description FlowControlHandler()
FlowControlHandler(boolean releaseMessages)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
channelInactive(ChannelHandlerContext ctx)
TheChannel
of theChannelHandlerContext
was registered is now inactive and reached its end of lifetime.void
channelRead(ChannelHandlerContext ctx, Object msg)
Invoked when the currentChannel
has read a message from the peer.void
channelReadComplete(ChannelHandlerContext ctx)
Invoked when the last message read by the current read operation has been consumed byChannelHandler.channelRead(ChannelHandlerContext, Object)
.void
handlerRemoved(ChannelHandlerContext ctx)
Gets called after theChannelHandler
was removed from the actual context and it doesn't handle events anymore.void
read(ChannelHandlerContext ctx)
InterceptsChannelHandlerContext.read()
.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
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
-
-
-
-
Method Detail
-
handlerRemoved
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception
Description copied from interface:ChannelHandler
Gets called after theChannelHandler
was removed from the actual context and it doesn't handle events anymore.- Specified by:
handlerRemoved
in interfaceChannelHandler
- Throws:
Exception
-
channelInactive
public void channelInactive(ChannelHandlerContext ctx) throws Exception
Description copied from interface:ChannelHandler
TheChannel
of theChannelHandlerContext
was registered is now inactive and reached its end of lifetime.- Specified by:
channelInactive
in interfaceChannelHandler
- Throws:
Exception
-
read
public void read(ChannelHandlerContext ctx)
Description copied from interface:ChannelHandler
InterceptsChannelHandlerContext.read()
.- Specified by:
read
in interfaceChannelHandler
-
channelRead
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
Description copied from interface:ChannelHandler
Invoked when the currentChannel
has read a message from the peer.- Specified by:
channelRead
in interfaceChannelHandler
- Throws:
Exception
-
channelReadComplete
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception
Description copied from interface:ChannelHandler
Invoked when the last message read by the current read operation has been consumed byChannelHandler.channelRead(ChannelHandlerContext, Object)
. IfChannelOption.AUTO_READ
is off, no further attempt to read an inbound data from the currentChannel
will be made untilChannelHandlerContext.read()
is called.- Specified by:
channelReadComplete
in interfaceChannelHandler
- Throws:
Exception
-
-