0
0
RabbitMQdevops~10 mins

Synchronous vs asynchronous communication in RabbitMQ - Interactive Practice

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

Complete the code to declare a queue named 'task_queue' in RabbitMQ.

RabbitMQ
channel.queue_declare(queue=[1])
Drag options to blanks, or click blank then click option'
A'task_queue'
Btask_queue
C'queue_task'
Dqueue_task
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the queue name
Using wrong queue name
2fill in blank
medium

Complete the code to publish a message 'Hello' to the 'task_queue'.

RabbitMQ
channel.basic_publish(exchange='', routing_key=[1], body='Hello')
Drag options to blanks, or click blank then click option'
A'hello'
B'default_queue'
C'queue_task'
D'task_queue'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong routing_key
Using exchange name instead of routing_key
3fill in blank
hard

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

RabbitMQ
def callback(ch, method, properties, body):
    print(f"Received {body}")
    ch.basic_ack(delivery_tag=[1])
Drag options to blanks, or click blank then click option'
Aproperties.delivery_tag
Bbody
Cmethod.delivery_tag
Dch.delivery_tag
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong parameter for delivery_tag
Not acknowledging message causing re-delivery
4fill in blank
hard

Fill both blanks to create a synchronous RPC style call using RabbitMQ.

RabbitMQ
channel.basic_publish(exchange='', routing_key=[1], properties=[2], body='Request')
Drag options to blanks, or click blank then click option'
A'rpc_queue'
Bcallback
Creply_to
Dpika.BasicProperties(reply_to='response_queue')
Attempts:
3 left
💡 Hint
Common Mistakes
Not setting reply_to property
Using wrong queue name for routing_key
5fill in blank
hard

Fill all three blanks to create an asynchronous consumer that listens to 'task_queue' and auto-acknowledges messages.

RabbitMQ
channel.basic_consume(queue=[1], on_message_callback=[2], auto_ack=[3])
channel.start_consuming()
Drag options to blanks, or click blank then click option'
A'task_queue'
Bcallback
CTrue
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Setting auto_ack to False causing manual ack needed
Wrong queue name
Wrong callback function