0
0
RabbitMQdevops~10 mins

Priority queues in RabbitMQ - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to declare a priority queue in RabbitMQ.

RabbitMQ
channel.queue_declare(queue='task_queue', arguments=[1])
Drag options to blanks, or click blank then click option'
A{'x-max-priority': 10}
B{'priority-max': 10}
C{'max-priority': 10}
D{'x-priority': 10}
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect argument keys like 'x-priority' or 'max-priority'.
2fill in blank
medium

Complete the code to publish a message with priority 5 to the priority queue.

RabbitMQ
channel.basic_publish(exchange='', routing_key='task_queue', body='Hello', properties=pika.BasicProperties(priority=[1]))
Drag options to blanks, or click blank then click option'
A15
B0
C10
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using a priority value outside the declared max priority range.
3fill in blank
hard

Fix the error in the queue declaration to enable priority support.

RabbitMQ
channel.queue_declare(queue='task_queue', arguments=[1])
Drag options to blanks, or click blank then click option'
A{'x-max-priority': 5}
B{'x-priority': 5}
C{'x-max-priority': '5'}
D{'priority': 5}
Attempts:
3 left
💡 Hint
Common Mistakes
Using string instead of integer for priority value.
Using wrong argument keys.
4fill in blank
hard

Fill both blanks to declare a priority queue and publish a message with priority 7.

RabbitMQ
channel.queue_declare(queue='task_queue', arguments=[1])
channel.basic_publish(exchange='', routing_key='task_queue', body='Task', properties=pika.BasicProperties(priority=[2]))
Drag options to blanks, or click blank then click option'
A{'x-max-priority': 10}
B7
C5
D{'priority': 7}
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong keys in queue declaration.
Setting message priority outside allowed range.
5fill in blank
hard

Fill all three blanks to declare a priority queue, publish a high priority message, and consume it.

RabbitMQ
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])
Drag options to blanks, or click blank then click option'
A{'x-max-priority': 15}
B10
CTrue
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect argument keys or values.
Setting auto_ack to False when automatic acknowledgment is intended.