RabbitMQ error timeout

[亡魂溺海] 提交于 2019-12-02 19:13:06

I've just solved a similar problem in python. In my case, it was solved by reducing the prefetch count on the consumer, so that it had fewer messages queued up in its receive buffer.

My theory is that the receive buffer on the consumer gets full, and then RMQ tries to write some other message to the consumer's socket and can't due to the consumer's socket being full. RMQ blocks on this socket, and eventually timeouts and just closes the connection on the consumer. Having a smaller prefetch queue means the socket receive buffer doesn't get filled, and RMQ is able to write whatever bookkeeping messages it was trying to do and so doesn't timeout on its writes nor close the connection.

This is just a theory though, but it seems to hold in my testing.

In Python, setting the prefetch count can be done like so:

subChannel.basicQos(10);

(Thanks to @shawn-guo for reminding me to add this code snippet)

Add more to @tul's answer.

subChannel.basicQos(10); 

Reducing consumer prefetch count does eliminate this timeout exception.
The default prefetch count is unlimited.

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