Netty Clients Limited Queue Reset Policy

Enabling OutMemoryError, connecting to a third-party server that cannot process requests fast enough.

Tried NioClientSocketChannelFactory to pass to the executor service with the limited queue and delete policy (ThreadPoolExecutor.DiscardPolicy), but still got an OutOfMemoryError.

What am I missing?

thanks

+4
source share
1 answer

If your client-side Netty channel write buffer is OutOfMemoryError and the server does not read it fast enough, you will see OutOfMemoryError on the client side. To avoid this, you should stop recording if Channel.isWritable() returns false . You will be notified with the channelInterestOpsChanged event when the status of Channel.writable' changes. Then, you can check again if Channel.writable' changes. Then, you can check again if Channel.isWritable () returns true` and continues recording.

If it is normal to discard pending data, I would simply not call Channel.write() if Channel.isWritable() returns false .

You can configure when the Channel.writable property Channel.writable changed using the watermark properties specified in the NioSocketChannelConfig . Also, check out the discard example that uses this technique.

+9
source

Source: https://habr.com/ru/post/1385039/


All Articles