In this article, you will learn how to send API requests using RabbitMQ.
When working with API in RabbitMQ, two queues are used:
- api_req - queue for incoming requests;
- api_resp - the queue that receives responses to requests (only if request_id is specified).
Structure of the sent JSON message
|request_id||string||"abcd1234"||Yes, if the response to the request is necessary||Request ID|
|Yes||API request path|
|body||JSON object||Yes||API request body|
Structure of the received JSON message
|Request response body|
How to send API requests in Go
You can send an API request using a script that calls RabbitMQ:
- Write and execute a script
- After executing the script, go to RabbitMQ → Queues
- Choose api_resp and get a response to the API request
How to send API requests via RabbitMQ Management Plugin
You can send an API request directly to RabbitMQ via api_req:
- Go to RabbitMQ → the Queues tab. Then select api_req and Publish message.
- After the request is sent, you can see its result in the same way as in the first method.