0
0
RabbitMQdevops~10 mins

AMQP protocol overview 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 queue named 'task_queue' in RabbitMQ.

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

Complete the code to publish a message 'Hello' to the default exchange with routing key 'task_queue'.

RabbitMQ
channel.basic_publish(exchange=[1], routing_key='task_queue', body='Hello')
Drag options to blanks, or click blank then click option'
A'amq.direct'
B'default'
C'task_queue'
D''
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'default' or 'amq.direct' instead of empty string
Confusing exchange name with queue name
3fill in blank
hard

Fix the error in the code to consume messages from 'task_queue' with manual acknowledgments.

RabbitMQ
channel.basic_consume(queue='task_queue', on_message_callback=callback, auto_ack=[1])
Drag options to blanks, or click blank then click option'
AFalse
BTrue
C'False'
DNone
Attempts:
3 left
💡 Hint
Common Mistakes
Using string 'False' instead of boolean False
Setting auto_ack to True disables manual ack
4fill in blank
hard

Fill both blanks to create a durable queue and publish a persistent message.

RabbitMQ
channel.queue_declare(queue='task_queue', durable=[1])
channel.basic_publish(exchange='', routing_key='task_queue', body='Hello', properties=[2])
Drag options to blanks, or click blank then click option'
ATrue
Bpika.BasicProperties(delivery_mode=2)
CFalse
Dpika.BasicProperties(delivery_mode=1)
Attempts:
3 left
💡 Hint
Common Mistakes
Not setting durable=True
Using delivery_mode=1 which is non-persistent
5fill in blank
hard

Fill all three blanks to create a direct exchange, bind a queue to it, and publish a message with routing key 'info'.

RabbitMQ
channel.exchange_declare(exchange=[1], exchange_type=[2])
channel.queue_bind(queue='log_queue', exchange=[1], routing_key=[3])
channel.basic_publish(exchange=[1], routing_key=[3], body='Log message')
Drag options to blanks, or click blank then click option'
A'direct_logs'
B'direct'
C'info'
D'logs'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong exchange type
Mismatching exchange names
Incorrect routing key