Pika python wait for RabbitMQ Publisher if queue reach limit

The RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.

If you are using arecent RabbitMQ version (like 3.7.5), you can set the overflow behavior to reject-publish. Then, in your code, use the channel_instance.confirm_delivery() method to enable publisher confirms. Finally, when the queue limit is reached, a basic.nack message will be sent back to your code and will raise a NackError exception that you can catch.

Read more here: Source link