D
D
d999992021-04-08 19:14:02
API
d99999, 2021-04-08 19:14:02

Is it possible to create a queue using rabbitMQ in which a request to another site will be sequentially executed for each user?

There is a task to communicate to the API of another site no more than once every 5 seconds. There can be many users.
Hence there is a need to create a queue (as in real life). And give users the opportunity to turn to another site in turn?

What is the best way to do this and what is the best way to use it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Mirilaczvili, 2021-04-08
@2ord

If the response to the client's request is not immediately issued, but with a delay due to restrictions due to the third-party API, then it is logical to introduce a request system. When requested, the client's application is registered, the data is entered into the DBMS, put in a queue, and a response is immediately issued with the application number and the expected time of readiness. When the queue handler takes the task, taking into account the delay of 5 seconds, receives a response from the API and enters the response in a form ready for subsequent reading in the DBMS for the corresponding ticket number. Regardless of the queue handler, clients ask for finished results. And if they are ready (checking by the column in the table), the answer is given. If not yet ready, the next expected window of time is returned. And so on, up to the limit of checks.
If, however, before answering, wait until 5 seconds pass, then such a system will quickly drown with an influx of requests and resources will be exhausted. Therefore, I do not consider RPC as a suitable work option.

S
Sergey Gornostaev, 2021-04-08
@sergey-gornostaev

With RabbitMQ and execute. Simply create a queue to which many clients will send jobs, and one consumer will read and execute from the job queue.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question