In RabbitMQ RPC, how does the client receive the reply from the server?
Think about how the client knows which reply belongs to its request.
RPC in RabbitMQ uses a temporary reply queue for each client. The client sends a request with a correlation ID and listens on this reply queue. The server sends the response back to this queue with the same correlation ID, allowing the client to match replies to requests.
Given the following simplified Python RabbitMQ RPC client snippet, what will be printed?
import pika import uuid connection = pika.BlockingConnection(pika.ConnectionParameters('localhost')) channel = connection.channel() result = channel.queue_declare(queue='', exclusive=True) callback_queue = result.method.queue corr_id = str(uuid.uuid4()) print(f"Waiting for reply with correlation ID: {corr_id}")
Look at how the correlation ID is generated and printed.
The code generates a UUID string and prints it with the message. The print statement is correct syntax in Python 3. The queue_declare call is valid and returns a queue name. So the output is the message with a UUID.
When setting up a reply queue for RPC in RabbitMQ, which queue property ensures the reply queue is deleted when the client disconnects?
Think about a queue that only the client uses and should disappear after disconnect.
Setting exclusive=true makes the queue accessible only by the connection that declared it and deletes it when the connection closes. This is ideal for temporary reply queues in RPC.
An RPC client sends requests to a server queue but never receives replies. Which is the most likely cause?
Check how the server sends the reply back to the client.
If the server does not set the reply_to property in the response, the client does not know where to listen for the reply, so it never receives it.
Put the following steps in the correct order for a RabbitMQ RPC client-server interaction.
Think about what the client must do before sending a request.
The client first creates a temporary reply queue, then sends the request with correlation ID and reply_to set. The server processes and replies to that queue. The client listens and matches replies by correlation ID.