Complete the code to declare a durable queue in RabbitMQ.
channel.queue_declare(queue='task_queue', durable=[1])
Setting durable=True ensures the queue survives RabbitMQ restarts, which is important for exactly-once processing.
Complete the code to acknowledge a message after processing it.
channel.basic_ack(delivery_tag=[1])The method.delivery_tag uniquely identifies the message to acknowledge it properly.
Fix the error in the code to enable publisher confirms for exactly-once delivery.
channel.[1]()The correct method to enable publisher confirms in RabbitMQ is confirm_select().
Fill both blanks to set message properties for persistent delivery and publish a message.
channel.[2]() channel.basic_publish(exchange='', routing_key='task_queue', body=message, properties=pika.BasicProperties(delivery_mode=[1]))
Setting delivery_mode=2 makes messages persistent. Calling confirm_select() enables publisher confirms.
Fill both blanks to create a consumer that processes messages exactly once with manual acknowledgments and prefetch count.
channel.basic_qos(prefetch_count=[1]) channel.basic_consume(queue='task_queue', on_message_callback=callback, auto_ack=[2]) channel.start_consuming()
Setting prefetch_count=1 limits unacknowledged messages to one at a time. auto_ack=False enables manual acknowledgments for exactly-once processing. start_consuming() starts the consumer loop.