0
0
RabbitMQdevops~20 mins

Reply-to queue pattern in RabbitMQ - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Reply-to Queue Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Understanding the purpose of the reply-to queue in RabbitMQ

What is the main purpose of the reply-to queue in the RabbitMQ reply-to queue pattern?

AIt acts as a dead-letter queue for expired messages.
BIt defines the queue where the original request message is published.
CIt specifies the queue where the consumer should send the response message.
DIt is used to store messages that failed to be delivered.
Attempts:
2 left
💡 Hint

Think about how the consumer knows where to send the reply.

💻 Command Output
intermediate
1:30remaining
Output of a basic RabbitMQ reply-to usage in Python

Given the following Python code snippet using pika to send a message with reply_to set, what will be printed by the consumer?

RabbitMQ
import pika

connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()

channel.queue_declare(queue='task_queue')

# Producer sends a message with reply_to
channel.basic_publish(
    exchange='',
    routing_key='task_queue',
    properties=pika.BasicProperties(reply_to='response_queue'),
    body='Hello')

print('Message sent with reply_to=response_queue')
AMessage sent with reply_to=response_queue
BError: reply_to property missing
CMessage sent with reply_to=task_queue
DNo output
Attempts:
2 left
💡 Hint

Look at the print statement after publishing the message.

Configuration
advanced
2:30remaining
Correct RabbitMQ consumer configuration for reply-to pattern

Which of the following consumer configurations correctly uses the reply_to property to send a response back to the producer?

A
channel.basic_consume(queue='task_queue', on_message_callback=callback)

def callback(ch, method, properties, body):
    response = body.decode().upper()
    ch.basic_publish(exchange='reply_exchange', routing_key=properties.reply_to, body=response)
    ch.basic_ack(delivery_tag=method.delivery_tag)
B
channel.basic_consume(queue='task_queue', on_message_callback=callback)

def callback(ch, method, properties, body):
    response = body.decode().lower()
    ch.basic_publish(exchange='', routing_key='task_queue', body=response)
    ch.basic_ack(delivery_tag=method.delivery_tag)
C
channel.basic_consume(queue='task_queue', on_message_callback=callback)

def callback(ch, method, properties, body):
    response = body.decode().upper()
    ch.basic_publish(exchange='', routing_key='', body=response)
    ch.basic_ack(delivery_tag=method.delivery_tag)
D
channel.basic_consume(queue='task_queue', on_message_callback=callback)

def callback(ch, method, properties, body):
    response = body.decode().upper()
    ch.basic_publish(exchange='', routing_key=properties.reply_to, body=response)
    ch.basic_ack(delivery_tag=method.delivery_tag)
Attempts:
2 left
💡 Hint

Check how the response is sent back using the reply_to property and the exchange.

Troubleshoot
advanced
2:00remaining
Diagnosing missing replies in reply-to pattern

A developer uses the reply-to queue pattern but notices the producer never receives replies. Which of the following is the most likely cause?

AThe producer did not set the <code>reply_to</code> property in the request message.
BThe consumer publishes the response to a different exchange than the default ('').
CThe consumer did not acknowledge the request message.
DThe producer queue is not declared before sending the request.
Attempts:
2 left
💡 Hint

Think about how the consumer knows where to send the reply.

🔀 Workflow
expert
3:00remaining
Correct sequence of steps in the RabbitMQ reply-to queue pattern

Arrange the following steps in the correct order for a typical RabbitMQ reply-to queue pattern workflow.

A2,1,3,4
B1,2,3,4
C1,3,2,4
D2,3,1,4
Attempts:
2 left
💡 Hint

Think about what the producer must do before sending the request.