0
0
RabbitMQdevops~10 mins

Work queue for task distribution 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 durable queue named 'task_queue'.

RabbitMQ
channel.queue_declare(queue='task_queue', durable=[1])
Drag options to blanks, or click blank then click option'
ANone
BFalse
CTrue
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Setting durable to False causes the queue to be deleted on server restart.
2fill in blank
medium

Complete the code to send a persistent message to the 'task_queue'.

RabbitMQ
channel.basic_publish(exchange='', routing_key='task_queue', body=message, properties=pika.BasicProperties(delivery_mode=[1]))
Drag options to blanks, or click blank then click option'
A1
B2
C0
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using delivery_mode=1 sends non-persistent messages.
3fill in blank
hard

Fix the error in the consumer code to acknowledge messages manually.

RabbitMQ
channel.basic_consume(queue='task_queue', on_message_callback=callback, auto_ack=[1])
Drag options to blanks, or click blank then click option'
ANone
BTrue
C0
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Setting auto_ack to True causes messages to be lost if the consumer crashes.
4fill in blank
hard

Fill both blanks to set prefetch count to 1 and declare a durable queue.

RabbitMQ
channel.basic_qos(prefetch_count=[1])
channel.queue_declare(queue='task_queue', durable=[2])
Drag options to blanks, or click blank then click option'
A1
B0
CTrue
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using prefetch_count=0 disables fair dispatch, and durable=False makes the queue temporary.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps each word to its length only if length is greater than 3.

RabbitMQ
lengths = { [1] : [2] for [3] in words if len([3]) > 3 }
Drag options to blanks, or click blank then click option'
Aword
Blen(word)
Ditem
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names in different parts of the comprehension.