Complete the code to declare a priority queue in RabbitMQ.
channel.queue_declare(queue='task_queue', arguments=[1])
The argument 'x-max-priority' is used to declare a priority queue in RabbitMQ with a maximum priority value.
Complete the code to publish a message with priority 5 to the priority queue.
channel.basic_publish(exchange='', routing_key='task_queue', body='Hello', properties=pika.BasicProperties(priority=[1]))
The priority property sets the message priority. Here, priority 5 is within the allowed range.
Fix the error in the queue declaration to enable priority support.
channel.queue_declare(queue='task_queue', arguments=[1])
The value for 'x-max-priority' must be an integer, not a string, and the key must be exactly 'x-max-priority'.
Fill both blanks to declare a priority queue and publish a message with priority 7.
channel.queue_declare(queue='task_queue', arguments=[1]) channel.basic_publish(exchange='', routing_key='task_queue', body='Task', properties=pika.BasicProperties(priority=[2]))
Declare the queue with 'x-max-priority' set to 10, then publish a message with priority 7.
Fill all three blanks to declare a priority queue, publish a high priority message, and consume it.
channel.queue_declare(queue='task_queue', arguments=[1]) channel.basic_publish(exchange='', routing_key='task_queue', body='Urgent', properties=pika.BasicProperties(priority=[2])) method_frame, header_frame, body = channel.basic_get(queue='task_queue', auto_ack=[3])
Declare the queue with max priority 15, publish a message with priority 10, and consume it with auto_ack set to True to acknowledge automatically.