Description
In this article, you will learn how to send API requests using RabbitMQ.
A unique parameter request_id is sent to identify requests.
Queues
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
Parameter | Type | Example | Required | Required | |
---|---|---|---|---|---|
request_id | string | "abcd1234" | Yes, if the response to the request is necessary | Request ID | |
request | string | api/v1.1/campaigns/triggers/import_and_start_batch | Yes | API request path | |
body | JSON object |
| Yes | API request body |
Structure of the received JSON message
Parameter | Type | Example | Required | |
---|---|---|---|---|
body | JSON object |
| Request response body | |
request_id | string | "abcd1234" | Request ID |
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.