简体   繁体   中英

Using pika.BlockingConnection I would like to consume messages from a queue then exit

I have written a consumer using pika.BlockingConnection and channel.start_consuming() that consumes messages from a specific queue, when the messages are depleted from the queue, the consumer waits indefinitely for the next message.

Is there a way I could specify some sort of timeout duration by which the start_consuming() would exit gracefully if no message has been fetched from the queue by the consumer within the specific time period.

I am using python 3.7.4 and pika 1.1.0 to consume from RabbitMQ 3.7.12.

Use the "consume generator" with a timeout.


the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow. RabbitMQ 团队监控rabbitmq-users邮件列表,并且有时只回答 StackOverflow 上的问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM