Complete the code to declare a queue named 'rpc_queue' in RabbitMQ.
channel.queue_declare(queue='[1]')
The queue named 'rpc_queue' is the standard name used for RPC requests in RabbitMQ examples.
Complete the code to send a message with a unique correlation_id for RPC.
channel.basic_publish(exchange='', routing_key='rpc_queue', properties=pika.BasicProperties(correlation_id='[1]'), body='Hello')
The correlation_id must be unique to match the reply with the request. 'unique_id_1' is an example of such an ID.
Fix the error in the code to consume replies from the reply queue using the correct queue name.
channel.basic_consume(queue='[1]', on_message_callback=on_response, auto_ack=True)
The reply queue is where the client listens for responses. It is usually a temporary or named 'reply_queue'.
Fill both blanks to set the reply_to property and correlation_id in the RPC request message.
properties = pika.BasicProperties(reply_to='[1]', correlation_id='[2]')
The 'reply_to' property tells the server where to send the response, usually a callback queue. The 'correlation_id' uniquely identifies the request.
Fill all three blanks to complete the RPC server callback function that sends a reply with the same correlation_id.
def on_request(ch, method, props, body): response = body.decode().upper() ch.basic_publish(exchange='', routing_key=props.[1], properties=pika.BasicProperties(correlation_id=props.[2]), body=response) ch.basic_ack(delivery_tag=method.[3])
The server sends the reply to the queue specified in props.reply_to, uses the same correlation_id to match the request, and acknowledges the message with delivery_tag.