0
0
RabbitMQdevops~10 mins

Headers exchange 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 headers exchange named 'logs_headers'.

RabbitMQ
channel.exchange_declare(exchange='logs_headers', exchange_type='[1]')
Drag options to blanks, or click blank then click option'
Aheaders
Btopic
Cdirect
Dfanout
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'direct' or 'topic' instead of 'headers' exchange type.
2fill in blank
medium

Complete the code to bind a queue named 'error_logs' to the headers exchange with header 'x-match' set to 'all'.

RabbitMQ
channel.queue_bind(queue='error_logs', exchange='logs_headers', arguments=[1])
Drag options to blanks, or click blank then click option'
A{'x-match': 'all', 'severity': 'error'}
B{'x-match': 'any', 'severity': 'error'}
C{'x-match': 'all', 'type': 'info'}
D{'x-match': 'any', 'type': 'error'}
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'any' instead of 'all' for strict matching.
3fill in blank
hard

Fix the error in the code to publish a message with headers 'severity' set to 'error' and 'format' set to 'pdf'.

RabbitMQ
channel.basic_publish(exchange='logs_headers', routing_key='', body='Error report', properties=pika.BasicProperties(headers=[1]))
Drag options to blanks, or click blank then click option'
A('severity', 'error', 'format', 'pdf')
B['severity', 'error', 'format', 'pdf']
C'severity=error, format=pdf'
D{'severity': 'error', 'format': 'pdf'}
Attempts:
3 left
💡 Hint
Common Mistakes
Using list or string instead of dictionary for headers.
4fill in blank
hard

Fill both blanks to declare a headers exchange and bind a queue with 'x-match' set to 'any'.

RabbitMQ
channel.exchange_declare(exchange='logs_headers', exchange_type='[1]')
channel.queue_bind(queue='info_logs', exchange='logs_headers', arguments=[2])
Drag options to blanks, or click blank then click option'
Aheaders
B{'x-match': 'all', 'type': 'info'}
C{'x-match': 'any', 'type': 'info'}
Ddirect
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'direct' exchange type or wrong 'x-match' value.
5fill in blank
hard

Fill all three blanks to publish a message with headers and bind a queue with matching headers.

RabbitMQ
channel.basic_publish(exchange='logs_headers', routing_key='', body='Info report', properties=pika.BasicProperties(headers=[1]))
channel.queue_bind(queue='info_logs', exchange='logs_headers', arguments=[2])
channel.exchange_declare(exchange='logs_headers', exchange_type='[3]')
Drag options to blanks, or click blank then click option'
A{'severity': 'info', 'format': 'json'}
B{'x-match': 'any', 'severity': 'info'}
Cheaders
D{'x-match': 'all', 'severity': 'error'}
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatch between publish headers and binding headers.
Wrong exchange type.