Complete the code to declare a queue named 'rpc_queue' in RabbitMQ.
channel.queue_declare(queue='[1]')
The queue name for the request-reply pattern is typically 'rpc_queue'. This code declares that queue.
Complete the code to send a message with a unique correlation_id for the RPC request.
channel.basic_publish(exchange='', routing_key='rpc_queue', properties=pika.BasicProperties(correlation_id='[1]'), body='Hello')
The correlation_id is a unique string to match requests and replies. 'corr_id_abc' is a typical example.
Fix the error in the code to consume messages from the callback queue with auto_ack enabled.
channel.basic_consume(queue='[1]', on_message_callback=on_response, auto_ack=True)
The client listens on a callback queue, often named 'callback_queue', to receive replies.
Fill both blanks to create a dictionary comprehension that filters messages with correlation_id matching 'corr_id_abc'.
filtered = {k: v for k, v in messages.items() if k [1] '[2]'}The comprehension keeps items where the key equals 'corr_id_abc', matching the request.
Fill all three blanks to create a dictionary comprehension that maps message IDs to bodies for messages with body length greater than 5.
result = { [1]: [2] for [3], [2] in messages.items() if len([2]) > 5 }The comprehension uses 'msg_id' as key and 'body' as value, iterating over messages.