Complete the code to declare a direct exchange named 'logs'.
channel.exchange_declare(exchange='logs', exchange_type=[1])
The direct exchange type routes messages with a routing key exactly matching the binding key.
Complete the code to bind queue 'error_logs' to exchange 'logs' with routing key 'error'.
channel.queue_bind(queue='error_logs', exchange='logs', routing_key=[1])
The queue 'error_logs' should bind with routing key 'error' to receive error messages.
Fix the error in the code to publish a message with routing key 'info' to exchange 'logs'.
channel.basic_publish(exchange='logs', routing_key=[1], body='System started')
The routing key must be 'info' to route the message correctly to queues bound with that key.
Fill both blanks to declare a topic exchange named 'topic_logs' and bind queue 'critical_logs' with binding key 'kern.critical'.
channel.exchange_declare(exchange='topic_logs', exchange_type=[1]) channel.queue_bind(queue='critical_logs', exchange='topic_logs', routing_key=[2])
Use topic exchange type to enable pattern matching in routing keys. The binding key 'kern.critical' matches messages with that routing key.
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.*'.
channel.basic_publish(exchange=[1], routing_key=[2], body='Kernel info message') channel.queue_bind(queue='info_logs', exchange='topic_logs', routing_key=[3])
Publish to 'topic_logs' exchange with routing key 'kern.info'. Bind queue with 'kern.*' to receive all messages starting with 'kern.' and one word after.