Where will the data been queued if Netty channel isWritable return false

与世无争的帅哥 提交于 2021-02-11 07:20:07

问题


From the Netty api, it shows the request will be queued if isWritable return false. Could I know where will the request be queued? In what case, the queue could be full and cause OOM issue?

Following is the document for isWritable()

Returns true if and only if the I/O thread will perform the requested write operation immediately. Any write requests made when this method returns false are queued until the I/O thread is ready to process the queued write requests.

https://netty.io/4.1/api/io/netty/channel/Channel.html#isWritable--


回答1:


It will be queued in an internal buffer maintained by netty. To avoid the system from going OOM you will have to override the method channelWritabilityChanged of the ChannelInboundHandler and do back pressure handling.

Here you can slow down the reading of the inbound data by using the autoread config of the channel and manually read the request as described here. Or if you are writing on a different thread you might need to block that thread.



来源:https://stackoverflow.com/questions/53824955/where-will-the-data-been-queued-if-netty-channel-iswritable-return-false

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!