I tried to use these functions: - basic_nack - basic_reject but I couldn't do it
I want an example of the nack in python using pika with one of these functions: - basic_nack - basic_reject
def callback(ch, method, properties, body):
ch.basic_reject(delivery_tag=method.delivery_tag)
return pika.exceptions.ChannelClosed: (406, 'PRECONDITION_FAILED - unknown delivery tag 1')
From the pika documentation the message rejection can be done like this:
import pika
connection = pika.BlockingConnection()
channel = connection.channel()
for method_frame, properties, body in channel.consume('test'):
channel.basic_reject(method_frame.delivery_tag)
Note that you need to pass delivery_tag value from method_frame object, which specifies which message is being rejected.
basic_reject() method also accepts additional argument requeue, which is by default True.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With