0
0
RabbitMQdevops~10 mins

Why reliability prevents message loss in RabbitMQ - Test Your Understanding

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
B0
CNone
DTrue
Attempts:
3 left
💡 Hint
Common Mistakes
Setting durable to False causes the queue to be deleted on restart.
2fill in blank
medium

Complete the code to publish a persistent message to the 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'
A2
B1
C0
D3
Attempts:
3 left
💡 Hint
Common Mistakes
Using delivery_mode=1 sends non-persistent messages that can be lost.
3fill in blank
hard

Fix the error in the consumer code to acknowledge messages manually.

RabbitMQ
channel.basic_consume(queue='task_queue', on_message_callback=callback, auto_ack=[1])
Drag options to blanks, or click blank then click option'
ANone
BFalse
CTrue
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using auto_ack=True causes messages to be lost if the consumer fails before processing.
4fill in blank
hard

Fill both blanks to declare 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=message, properties=pika.BasicProperties(delivery_mode=[2]))
Drag options to blanks, or click blank then click option'
ATrue
BFalse
C2
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Setting durable or delivery_mode incorrectly causes messages to be lost on restart.
5fill in blank
hard

Fill the blanks to consume messages with manual acknowledgment and durable queue.

RabbitMQ
channel.queue_declare(queue='task_queue', durable=[1])
channel.basic_consume(queue='task_queue', on_message_callback=callback, auto_ack=[2])
channel.start_consuming()
Drag options to blanks, or click blank then click option'
ATrue
BFalse
CNone
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using auto_ack=True causes message loss if consumer crashes.