RPC (Remote Procedure Call) allows a client to send a request message to a server and wait for a response, enabling communication between distributed systems.
Click to reveal answer
beginner
Which RabbitMQ feature is commonly used to implement RPC?
The 'reply_to' queue and 'correlation_id' properties are used to match requests with responses in RabbitMQ RPC.
Click to reveal answer
intermediate
What role does the 'correlation_id' play in RabbitMQ RPC?
It uniquely identifies the request so the client can match the response to the correct request.
Click to reveal answer
intermediate
How does the RPC server know where to send the response?
The server reads the 'reply_to' property from the request message, which contains the queue name for the response.
Click to reveal answer
intermediate
Why should the RPC client use a unique callback queue?
To receive responses only for its own requests and avoid mixing messages from other clients.
Click to reveal answer
In RabbitMQ RPC, what property does the client set to receive the server's response?
Areply_to
Bcontent_type
Cdelivery_mode
Dexpiration
✗ Incorrect
The 'reply_to' property tells the server which queue to send the response to.
What is the purpose of the 'correlation_id' in RabbitMQ RPC?
ATo identify the client
BTo set message priority
CTo match the response with the request
DTo specify message expiration
✗ Incorrect
The 'correlation_id' helps the client match the response to the original request.
Which queue type is typically used by the RPC client to receive responses?
ADurable queue
BExclusive callback queue
CFanout queue
DDead-letter queue
✗ Incorrect
An exclusive callback queue is used so only the client receives its responses.
What happens if the RPC server does not set the 'correlation_id' in the response?
AThe client cannot match the response to the request
BThe message is discarded
CThe server crashes
DThe response is sent to all clients
✗ Incorrect
Without 'correlation_id', the client cannot identify which request the response belongs to.
Which RabbitMQ exchange type is commonly used to send RPC requests?
AFanout exchange
BTopic exchange
CHeaders exchange
DDirect exchange
✗ Incorrect
Direct exchange routes messages to queues based on routing keys, suitable for RPC requests.
Explain how an RPC client and server communicate using RabbitMQ.
Think about the message properties and queues involved.
You got /4 concepts.
Describe the purpose of the 'reply_to' and 'correlation_id' properties in RabbitMQ RPC.
These properties help the client and server coordinate messages.
You got /2 concepts.
Practice
(1/5)
1. What is the main role of the RPC server in RabbitMQ RPC communication?
easy
A. To store messages permanently without processing
B. To send requests and wait for responses
C. To receive requests, process them, and send back responses
D. To monitor network traffic between clients
Solution
Step 1: Understand RPC server role
The RPC server listens for requests on a queue and processes them.
Step 2: Identify server response behavior
After processing, the server sends the result back to the client via a reply queue.
Final Answer:
To receive requests, process them, and send back responses -> Option C
Quick Check:
RPC server handles requests and replies [OK]
Hint: Server processes requests and replies, client sends requests [OK]
Common Mistakes:
Confusing client and server roles
Thinking server only stores messages
Assuming server sends requests
2. Which of the following is the correct way to declare a callback queue for RPC replies in Python pika client?
easy
A. channel.queue_declare(queue='rpc_queue')
B. result = channel.queue_declare(queue='', exclusive=True)
C. channel.basic_publish(exchange='', routing_key='rpc_queue')
D. channel.basic_consume(queue='rpc_queue', on_message_callback=callback)
Solution
Step 1: Identify callback queue declaration
For RPC replies, a temporary exclusive queue is declared with empty name and exclusive=True.
Step 2: Match syntax with pika usage
Using queue_declare with queue='' and exclusive=True creates a unique callback queue.
Final Answer:
result = channel.queue_declare(queue='', exclusive=True) -> Option B
Quick Check:
Exclusive empty queue for callback = result = channel.queue_declare(queue='', exclusive=True) [OK]
Hint: Use empty queue name with exclusive=True for callback queue [OK]
Common Mistakes:
Declaring fixed queue name for callback
Using basic_publish instead of queue_declare
Not setting exclusive=True for callback queue
3. Given this Python RPC client snippet, what will be printed?
basic_consume is set but start_consuming() is not called to begin processing.
Step 2: Verify other parts
Correlation_id usage and ack are correct; queue name matches.
Final Answer:
Missing call to start consuming messages -> Option A
Quick Check:
start_consuming() needed to process messages [OK]
Hint: Always call start_consuming() after basic_consume [OK]
Common Mistakes:
Forgetting start_consuming() call
Misusing correlation_id property
Not acknowledging messages
5. You want to implement an RPC client that sends multiple requests concurrently and matches replies correctly. Which approach best ensures correct matching of replies to requests?
hard
A. Create a new reply queue for each request without correlation_id
B. Send all requests with the same correlation_id to simplify matching
C. Use a single shared reply queue without correlation_id
D. Use a unique correlation_id for each request and check it on reply
Solution
Step 1: Understand concurrency in RPC client
Multiple requests need unique IDs to identify replies correctly.
Step 2: Evaluate options for reply matching
Using unique correlation_id per request allows client to match replies properly.
Final Answer:
Use a unique correlation_id for each request and check it on reply -> Option D
Quick Check:
Unique correlation_id matches replies to requests [OK]
Hint: Assign unique correlation_id per request for reply matching [OK]
Common Mistakes:
Using same correlation_id for all requests
Not using correlation_id at all
Creating many reply queues unnecessarily
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.