0
0
RabbitMQdevops~10 mins

Message durability and persistence 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 durable queue in RabbitMQ.

RabbitMQ
channel.queue_declare(queue='task_queue', durable=[1])
Drag options to blanks, or click blank then click option'
AFalse
BTrue
C'yes'
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string instead of a boolean
Setting durable to False
2fill in blank
medium

Complete the code to publish a persistent message to a queue.

RabbitMQ
channel.basic_publish(exchange='', routing_key='task_queue', body=message, properties=pika.BasicProperties(delivery_mode=[1]))
Drag options to blanks, or click blank then click option'
A1
B0
C2
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using delivery_mode=1 which is non-persistent
Using delivery_mode=0 which is invalid
3fill in blank
hard

Fix the error in the code to ensure both queue and messages are durable.

RabbitMQ
channel.queue_declare(queue='task_queue', durable=[1])
channel.basic_publish(exchange='', routing_key='task_queue', body=message, properties=pika.BasicProperties(delivery_mode=[2]))
Drag options to blanks, or click blank then click option'
AFalse
BTrue
C1
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up delivery_mode values
Not setting queue durable to True
4fill in blank
hard

Fill both blanks to declare a durable queue and publish a persistent message with correct properties.

RabbitMQ
channel.queue_declare(queue='[1]', durable=[2])
channel.basic_publish(exchange='', routing_key='[1]', body=msg, properties=pika.BasicProperties(delivery_mode=2))
Drag options to blanks, or click blank then click option'
Atask_queue
BFalse
CTrue
Dlogs
Attempts:
3 left
💡 Hint
Common Mistakes
Using different queue names
Setting durable to False
5fill in blank
hard

Fill all three blanks to declare a durable queue, publish a persistent message, and set message expiration to 60000 ms.

RabbitMQ
channel.queue_declare(queue='[1]', durable=[2])
channel.basic_publish(exchange='', routing_key='[1]', body=msg, properties=pika.BasicProperties(delivery_mode=[3], expiration='60000'))
Drag options to blanks, or click blank then click option'
Atask_queue
BTrue
C2
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using delivery_mode other than 2
Setting durable to False
Mismatched queue names