Complete the code to declare a queue named 'task_queue' in RabbitMQ.
channel.queue_declare(queue=[1])The queue name must be a string, so it needs to be enclosed in quotes.
Complete the code to publish a message 'Hello' to the default exchange with routing key 'task_queue'.
channel.basic_publish(exchange=[1], routing_key='task_queue', body='Hello')
To publish to the default exchange, use an empty string ('') as the exchange name.
Fix the error in the code to consume messages from 'task_queue' with manual acknowledgments.
channel.basic_consume(queue='task_queue', on_message_callback=callback, auto_ack=[1])
To manually acknowledge messages, set auto_ack to False (boolean, not string).
Fill both blanks to create a durable queue and publish a persistent message.
channel.queue_declare(queue='task_queue', durable=[1]) channel.basic_publish(exchange='', routing_key='task_queue', body='Hello', properties=[2])
Setting durable=True makes the queue survive server restarts.
Setting delivery_mode=2 makes the message persistent.
Fill all three blanks to create a direct exchange, bind a queue to it, and publish a message with routing key 'info'.
channel.exchange_declare(exchange=[1], exchange_type=[2]) channel.queue_bind(queue='log_queue', exchange=[1], routing_key=[3]) channel.basic_publish(exchange=[1], routing_key=[3], body='Log message')
The exchange is named 'direct_logs' of type 'direct'.
The queue is bound with routing key 'info'.
Messages published with routing key 'info' go to 'log_queue'.