0
0
RabbitMQdevops~10 mins

Why exchanges route messages to queues 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 topic exchange named 'logs'.

RabbitMQ
channel.exchange_declare(exchange='[1]', exchange_type='topic')
Drag options to blanks, or click blank then click option'
Amessages
Bqueue
Clogs
Ddirect
Attempts:
3 left
💡 Hint
Common Mistakes
Using exchange type instead of exchange name
Using queue name instead of exchange name
2fill in blank
medium

Complete the code to bind the queue 'error_logs' to the 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'
Ainfo
Bwarning
Cdebug
Derror
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong routing key like 'info' or 'debug'
3fill in blank
hard

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

RabbitMQ
channel.basic_publish(exchange='logs', routing_key='[1]', body='System started')
Drag options to blanks, or click blank then click option'
Ainfo
Berror
Cwarning
Dstart
Attempts:
3 left
💡 Hint
Common Mistakes
Using routing key that does not match queue bindings
4fill in blank
hard

Fill both blanks to create a binding where the queue 'all_logs' receives all messages regardless of routing key.

RabbitMQ
channel.queue_bind(queue='all_logs', exchange='logs', routing_key='[1]')
channel.basic_publish(exchange='logs', routing_key='[2]', body='Test message')
Drag options to blanks, or click blank then click option'
B*
C#
Dall
Attempts:
3 left
💡 Hint
Common Mistakes
Using '*' which matches only one word
Using empty string which matches no keys
5fill in blank
hard

Fill all three blanks to create a topic exchange 'topic_logs', bind queue 'kern_logs' to routing key 'kern.*', and publish a message with routing key 'kern.critical'.

RabbitMQ
channel.exchange_declare(exchange='[1]', exchange_type='topic')
channel.queue_bind(queue='kern_logs', exchange='topic_logs', routing_key='[2]')
channel.basic_publish(exchange='topic_logs', routing_key='[3]', body='Kernel critical error')
Drag options to blanks, or click blank then click option'
Atopic_logs
Bkern.*
Ckern.critical
Ddirect_logs
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong exchange name
Using incorrect routing key patterns