0
0
RabbitMQdevops~10 mins

Fanout exchange (broadcast) 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 fanout exchange named 'logs'.

RabbitMQ
channel.exchange_declare(exchange='logs', exchange_type=[1])
Drag options to blanks, or click blank then click option'
Afanout
Bdirect
Ctopic
Dheaders
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'direct' or 'topic' instead of 'fanout' for broadcast.
2fill in blank
medium

Complete the code to bind a queue named 'queue1' to the 'logs' fanout exchange.

RabbitMQ
channel.queue_bind(queue='queue1', exchange='logs', routing_key=[1])
Drag options to blanks, or click blank then click option'
A'info'
B'logs'
C''
D'queue1'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a routing key other than empty string for fanout exchange binding.
3fill in blank
hard

Fix the error in publishing a message to the 'logs' fanout exchange.

RabbitMQ
channel.basic_publish(exchange='logs', routing_key=[1], body='Hello World!')
Drag options to blanks, or click blank then click option'
A'queue1'
B''
C'logs'
D'info'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-empty routing key when publishing to a fanout exchange.
4fill in blank
hard

Fill both blanks to declare a durable fanout exchange named 'broadcast' and bind 'queue2' to it.

RabbitMQ
channel.exchange_declare(exchange='broadcast', exchange_type=[1], durable=[2])
channel.queue_bind(queue='queue2', exchange='broadcast', routing_key='')
Drag options to blanks, or click blank then click option'
Afanout
Bdirect
CTrue
DFalse
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'direct' instead of 'fanout' exchange type.
Setting durable to False when persistence is needed.
5fill in blank
hard

Fill all three blanks to publish a persistent message 'Update' to the 'broadcast' fanout exchange with empty routing key.

RabbitMQ
channel.basic_publish(exchange='broadcast', routing_key=[1], body='Update', properties=pika.BasicProperties(delivery_mode=[2], content_type=[3]))
Drag options to blanks, or click blank then click option'
A'queue2'
B''
C'text/plain'
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-empty routing key for fanout exchange.
Not setting delivery_mode to 2 for persistence.