Search code examples
javaasynchronousnettyflow-controlevent-loop

Java Netty setAutoRead


Does Netty 4(or 5) continue reading while the handler chain is invoked ? Like reading in the background and filling up a huge queue and processing all reads after the handler chain is completely ready ?

I'm asking because I want to save incoming buffers to a file but files are blocking and if there are more incoming messages than the hard drive can handle do those messages queue up or does blocking the event simply stops the event queue from reading more messages ? On the sending side I use FileRegion so flow control for the writer is given.

I looked into the source but I'm not entirely sure how those ChannelInvokers work, it seems that if no one is specified a default one is created using eventLoop.next().

Would be nice if someone could help me to make sure that I'm not introducing a potential flow control bug...

I saw the option setAutoRead but I'm pretty sure this does something different.


Solution

  • If you want to do something like this you should specify a custom DefaultEventExecutorGroup when adding the handler that writes to the FS. This way you will hand-over the work from the EventLoop and so not block anything here.