RabbitMQ error timeout

前端 未结 2 1082
清酒与你
清酒与你 2021-02-01 19:40

I\'ve set up RabbitMQ in order to parse some 20.000 requests from an external API but it keeps timing out after a few minutes. It does get to correctly parse about 2000 out of t

相关标签:
2条回答
  • 2021-02-01 20:08

    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)

    0 讨论(0)
  • 2021-02-01 20:19

    Add more to @tul's answer.

    subChannel.basicQos(10); 
    

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

    0 讨论(0)
提交回复
热议问题