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 quotes around it.
Complete the code to publish a message 'Hello' to the 'task_queue'.
channel.basic_publish(exchange='', routing_key=[1], body='Hello')
The routing_key must match the queue name as a string to send the message correctly.
Fix the error in the batch publishing code by completing the blank.
channel.confirm_select() for message in messages: channel.basic_publish(exchange='', routing_key='task_queue', body=message) channel.[1]()
wait_for_confirms_or_die() waits for all messages to be confirmed or raises an error if any fail.
Fill both blanks to create a batch publish loop that confirms messages.
channel.[1]() for msg in batch: channel.basic_publish(exchange='', routing_key='task_queue', body=msg) channel.[2]()
confirm_select() enables confirm mode; wait_for_confirms_or_die() waits for all confirms after publishing.
Fill all three blanks to create a dictionary comprehension that batches messages by length greater than 5.
batched = {msg[1]2: msg for msg in messages if len(msg) [2] 5 and msg [3] 'error'}We square the message (symbolically), filter messages longer than 5, and exclude those equal to 'error'.