0
0
RabbitMQdevops~10 mins

Reply-to queue pattern 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 temporary reply queue in RabbitMQ.

RabbitMQ
channel.queue_declare(queue=[1], exclusive=True)
Drag options to blanks, or click blank then click option'
A""
B"main_queue"
C"reply_queue"
D"task_queue"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a fixed queue name instead of an empty string.
Not setting the queue as exclusive.
2fill in blank
medium

Complete the code to set the reply_to property in the message properties.

RabbitMQ
channel.basic_publish(exchange='', routing_key='task_queue', properties=pika.BasicProperties(reply_to=[1]), body='Hello')
Drag options to blanks, or click blank then click option'
A"main_queue"
B"callback_queue"
Ccallback_queue
Dreply_queue
Attempts:
3 left
💡 Hint
Common Mistakes
Using a quoted string literal instead of the variable.
Using the wrong queue name.
3fill in blank
hard

Fix the error in the callback function to correctly acknowledge the message.

RabbitMQ
def on_response(ch, method, props, body):
    if props.correlation_id == corr_id:
        response = body
    ch.basic_ack([1])
Drag options to blanks, or click blank then click option'
Amethod.delivery_tag
Bprops.delivery_tag
Cbody.delivery_tag
Dch.delivery_tag
Attempts:
3 left
💡 Hint
Common Mistakes
Using properties or channel instead of method for delivery tag.
Not acknowledging the message at all.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps words to their lengths only if length is greater than 3.

RabbitMQ
{word: [1] for word in words if [2] > 3}
Drag options to blanks, or click blank then click option'
Alen(word)
Cword
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself instead of its length.
Checking the word instead of its length in the condition.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps uppercase keys to values only if value is positive.

RabbitMQ
result = { [1]: [2] for k, v in data.items() if v [3] 0 }
Drag options to blanks, or click blank then click option'
Ak.upper()
Bv
C>
Dk.lower()
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase keys instead of uppercase.
Using wrong comparison operators.
Swapping keys and values.