0
0
RabbitMQdevops~10 mins

Message queue use cases 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 in RabbitMQ.

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

Complete the code to publish a message to a queue.

RabbitMQ
channel.basic_publish(exchange='', routing_key=[1], body=message)
Drag options to blanks, or click blank then click option'
A""
Bmessage
C"task_queue"
Dexchange
Attempts:
3 left
💡 Hint
Common Mistakes
Using empty string or variable instead of queue name.
3fill in blank
hard

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

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'
Amethod.delivery_tag
Bbody
Cproperties.delivery_tag
Dch.delivery_tag
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong parameter for delivery_tag.
4fill in blank
hard

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

RabbitMQ
channel.queue_declare(queue='task_queue', durable=[1])
channel.basic_publish(exchange='', routing_key='task_queue', body=message, 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
Setting durable to False or missing delivery_mode=2.
5fill in blank
hard

Fill all three blanks to set up a fanout exchange and bind a queue to it.

RabbitMQ
channel.exchange_declare(exchange=[1], exchange_type=[2])
channel.queue_bind(exchange=[3], queue='logs')
Drag options to blanks, or click blank then click option'
A"logs"
B"fanout"
C"logs_exchange"
D"direct"
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong exchange type or mismatched exchange names.