user3599803
user3599803

Reputation: 7044

rabbitmq pika don't take more than one job when using a thread

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?

Upvotes: 0

Views: 357

Answers (1)

Luke Bakken
Luke Bakken

Reputation: 9657

As long as you are setting the channel's QoS value via the channel.basic_qos method, your consumer will not get more unacknowledged messages than specified by prefetch_count.

If you use the prefetch_count=1 argument, your consumer will only get one message at a time and will not get more until basic_ack is called for that message.

If, for some reason, you see something different, share all of your code as an attachment or link in a message on the pika-python mailing list and I will check it out.

Upvotes: 1

Related Questions