0

I have a problem of ConnectionResetError when I block the IOLoop that channel.start_consuming() is running for a long time. So I've read this code:
https://github.com/pika/pika/blob/0.12.0/examples/basic_consumer_threaded.py
In this code the job is running in a background thread.

The problem is, when my job is running in a thread, The worker can still take more jobs, (i.e, keep getting on_message callbacks). But I don't want my worker to process more than one job at a time.
What should I do? Is it possible to inform the queue that the worker is 'busy' and can't accept jobs for some time?

4

1 回答 1

1

只要您通过该channel.basic_qos方法设置通道的 QoS 值,您的消费者将不会收到比指定的更多未确认消息prefetch_count

如果您使用该prefetch_count=1参数,您的消费者一次只会收到一条消息,并且basic_ack在为该消息调用之前不会获得更多消息。

如果由于某种原因,您看到了不同的内容,请将您的所有代码作为附件或链接分享到pika-python邮件列表中的邮件中,我会检查出来。


注意: RabbitMQ 团队会监控rabbitmq-users 邮件列表,有时只会在 StackOverflow 上回答问题。

于 2019-02-06T20:26:00.763 回答