0
0
RabbitMQdevops~10 mins

Binding keys and routing keys 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 direct exchange named 'logs'.

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

Complete the code to bind queue 'error_logs' to exchange 'logs' with routing key 'error'.

RabbitMQ
channel.queue_bind(queue='error_logs', exchange='logs', routing_key=[1])
Drag options to blanks, or click blank then click option'
A'error'
B'debug'
C'warning'
D'info'
Attempts:
3 left
💡 Hint
Common Mistakes
Binding with wrong routing keys like 'info' or 'debug'.
3fill in blank
hard

Fix the error in the code to publish a message with routing key 'info' to exchange 'logs'.

RabbitMQ
channel.basic_publish(exchange='logs', routing_key=[1], body='System started')
Drag options to blanks, or click blank then click option'
A'warning'
B'error'
C'start'
D'info'
Attempts:
3 left
💡 Hint
Common Mistakes
Using routing keys that do not match any binding key, causing message loss.
4fill in blank
hard

Fill both blanks to declare a topic exchange named 'topic_logs' and bind queue 'critical_logs' with binding key 'kern.critical'.

RabbitMQ
channel.exchange_declare(exchange='topic_logs', exchange_type=[1])
channel.queue_bind(queue='critical_logs', exchange='topic_logs', routing_key=[2])
Drag options to blanks, or click blank then click option'
Atopic
Bdirect
C'kern.critical'
D'critical.kern'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'direct' exchange type for topic routing.
Swapping parts of the binding key incorrectly.
5fill in blank
hard

Fill all three blanks to publish a message with routing key 'kern.info' to exchange 'topic_logs' and bind queue 'info_logs' with binding key 'kern.*'.

RabbitMQ
channel.basic_publish(exchange=[1], routing_key=[2], body='Kernel info message')
channel.queue_bind(queue='info_logs', exchange='topic_logs', routing_key=[3])
Drag options to blanks, or click blank then click option'
A'topic_logs'
B'kern.info'
C'kern.*'
D'info_logs'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong exchange name in publish.
Binding with incorrect pattern that won't match routing key.