A. The variable corr_id is not defined in the callback scope
B. The auto_ack parameter should be False
C. The correlation_id property is not set in the reply message
D. The queue name 'reply_queue' is incorrect
Solution
Step 1: Check variable scope in callback function
The callback uses corr_id but it is not passed or declared inside the function, causing a NameError or mismatch.
Step 2: Understand variable scope and fix
To fix, corr_id should be accessible inside on_response, either by passing it or declaring as global or closure variable.
Final Answer:
The variable corr_id is not defined in the callback scope -> Option A
Quick Check:
corr_id must be in callback scope [OK]
Hint: Ensure corr_id is accessible inside callback function [OK]
Common Mistakes:
Ignoring variable scope issues
Changing auto_ack unnecessarily
Assuming queue name is wrong without checking
5. You want to implement a RabbitMQ RPC client that sends multiple requests and matches replies correctly. Which approach best uses correlation_id to handle multiple outstanding requests?
hard
A. Use the same correlation_id for all requests to simplify matching
B. Set correlation_id only on the first request and ignore for others
C. Do not set correlation_id and rely on message order in the queue
D. Generate a unique correlation_id for each request and store a mapping of IDs to callbacks or futures