I use basic_consume () to receive messages and basic_cancel to cancel consumption, but there is a problem.
Here is the pika.channel code
def basic_consume(self, consumer_callback, queue='', no_ack=False, exclusive=False, consumer_tag=None): """Sends the AMQP command Basic.Consume to the broker and binds messages for the consumer_tag to the consumer callback. If you do not pass in a consumer_tag, one will be automatically generated for you. Returns the consumer tag. For more information on basic_consume, see: http://www.rabbitmq.com/amqp-0-9-1-reference.html
As you can see every time I cancel consumption, consumer_tag is added to the list with the list. And if I use this tag again in basic_consume, a duplicateConsumer exception will be thrown. Well, I could use a new user_tag every time, but actually it is not. Because sooner or later, the generated tag will exactly match some of the previous ones.
How can I pause and resume consumption gracefully in pika?
source share