0
0
RabbitMQdevops~10 mins

RPC vs direct API calls in RabbitMQ - Visual Side-by-Side Comparison

Choose your learning style9 modes available
Process Flow - RPC vs direct API calls
Client sends request
Direct API Call
Server processes request
Server sends response
Client receives response
RPC via RabbitMQ
Message queued
Server consumes message
Server processes and sends reply
Client receives reply message
Shows two ways a client can get a response from a server: direct API calls and RPC using RabbitMQ messaging.
Execution Sample
RabbitMQ
Client sends request -> Server processes -> Server sends response -> Client receives response
This traces the steps of a client requesting data and receiving a response either directly or via RabbitMQ RPC.
Process Table
StepActionMethodMessage StateResult
1Client sends requestDirect APIRequest sent over HTTPServer receives request
2Server processes requestDirect APIProcessing requestResponse ready
3Server sends responseDirect APIResponse sent over HTTPClient receives response
4Client sends requestRPC via RabbitMQMessage published to queueMessage queued
5Server consumes messageRPC via RabbitMQMessage removed from queueServer processing
6Server processes requestRPC via RabbitMQProcessing messageReply message ready
7Server sends replyRPC via RabbitMQReply published to reply queueReply queued
8Client receives replyRPC via RabbitMQReply consumed from queueClient gets response
9EndBothNo more messagesProcess complete
💡 Execution stops after client receives response in both methods.
Status Tracker
VariableStartAfter Step 1After Step 4After Step 7Final
RequestNoneSent (HTTP)Sent (MQ message)ProcessedResponse received
ResponseNoneNoneNoneSent (MQ reply)Received by client
QueueEmptyEmptyHas request messageHas reply messageEmpty
Key Moments - 2 Insights
Why does the RPC method use a queue instead of sending the request directly?
Because in RPC via RabbitMQ, the client sends a message to a queue so the server can process it asynchronously. This is shown in execution_table rows 4 and 5 where the message is queued and then consumed.
How does the client get the response in the direct API call compared to RPC?
In direct API calls, the client waits for the server to respond over HTTP immediately (rows 1-3). In RPC, the client listens for a reply message on a reply queue (rows 7-8).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step does the server start processing the RPC message?
AStep 3
BStep 7
CStep 5
DStep 2
💡 Hint
Check the 'Server consumes message' action in the execution_table at step 5.
At which step does the client receive the response in the direct API call?
AStep 3
BStep 1
CStep 8
DStep 6
💡 Hint
Look for 'Client receives response' under Direct API in execution_table row 3.
If the queue is empty in the Final column, what does that mean?
AThe server has not processed the request yet
BThe reply message was consumed by the client
CThe reply message was sent and is waiting in the queue
DThe client has not sent the request
💡 Hint
Refer to variable_tracker row 'Queue' showing it is empty in the Final column means messages were consumed.
Concept Snapshot
RPC vs Direct API Calls:
- Direct API: Client sends HTTP request, waits for immediate response.
- RPC with RabbitMQ: Client sends message to queue, server processes asynchronously.
- RPC uses queues for decoupling and async processing.
- Direct API is synchronous and simpler but less flexible.
- RPC requires client to listen for reply messages.
Full Transcript
This visual execution compares two ways a client communicates with a server: direct API calls and RPC using RabbitMQ. In direct API calls, the client sends an HTTP request and waits for the server to respond immediately. The execution table shows steps 1 to 3 covering this flow. In RPC, the client sends a message to a RabbitMQ queue (step 4), the server consumes and processes it (steps 5 and 6), then sends a reply message back to a reply queue (step 7). The client listens and receives this reply (step 8). Variables like Request, Response, and Queue change state as messages move through the system. Key moments clarify why RPC uses queues and how responses are received differently. The quiz tests understanding of when processing and responses happen in each method. The snapshot summarizes the main differences and use cases for RPC and direct API calls.