0
0
RabbitMQdevops~10 mins

Why advanced features handle edge cases 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
BNone
CTrue
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using durable=False causes the queue to be deleted on server restart.
2fill in blank
medium

Complete the code to enable message acknowledgments to handle message loss edge cases.

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
CNone
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Setting auto_ack=True can cause message loss if the consumer fails before processing.
3fill in blank
hard

Fix the error in the code to set message persistence correctly.

RabbitMQ
channel.basic_publish(exchange='', routing_key='task_queue', body=message, properties=pika.BasicProperties([1]=2))
Drag options to blanks, or click blank then click option'
Adeliverymode
BdeliveryMode
Cdelivery_modee
Ddelivery_mode
Attempts:
3 left
💡 Hint
Common Mistakes
Misspelling the property name causes the message to be non-persistent.
4fill in blank
hard

Fill both blanks to create a queue with dead-letter exchange and message TTL to handle message expiration edge cases.

RabbitMQ
args = {'x-dead-letter-exchange': [1], 'x-message-ttl': [2]
channel.queue_declare(queue='task_queue', arguments=args)
Drag options to blanks, or click blank then click option'
A'dead_letter_exchange'
B'dlx'
C60000
D30000
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong exchange name or TTL value causes messages to not expire or be lost.
5fill in blank
hard

Fill the blanks to set up a consumer with prefetch count and manual acknowledgments to handle load and failure edge cases.

RabbitMQ
channel.basic_qos(prefetch_count=[1])
channel.basic_consume(queue='task_queue', on_message_callback=callback, auto_ack=[2])
channel.start_consuming()  # Starts consuming messages
Drag options to blanks, or click blank then click option'
A1
BFalse
CTrue
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Setting prefetch_count too high can overload the consumer.
Using auto_ack=True risks losing messages if the consumer crashes.