Friends. This is a question for you. Webhook bot. Now

my bot takes the message and puts it in the "received" queue. Then, the listener looks to see if the "received" queue is not empty, it takes the message, sends it to the receive handler, and puts the message to be sent in the "send" queue. Then another listener looks to see if the send queue is not empty, he takes these messages and sends them out. The question is, does it make sense to put it all in queues for multi-threading or does a bot using webhooks process everything quickly and there is no point in it. That is, if you take a message, immediately process it and immediately send it, the essence will be the same?

3 ответов

10 просмотров

Those queues exist so that you can manage how many queries you do to the bot api. Depending on what your bot use case is and the amount of chats it has to process and react, your bot could reach flood limits, for example 20 messages/minute at the same chat, keyboard or message editions can easy lead to flood_waits. with queues you have the control over sending queries, set a proprity

Alex- Автор вопроса
Fabian Pastor
Those queues exist so that you can manage how many...

Interesting, thank you, I didn’t consider the question from this point of view. Then perhaps there will be no queues

The "received" queue seems pointless. And the "send" queue too if there is just one listener that works down the queue in order. The queue in this case is just a buffer that holds data to be processed but its not gonna speed up anything. You need multiple listeners working on the "send" queue to make it faster. That said if you have a small bot with outgoing requests peaking at a just few per second you can ignore this completely and not send request in parallel.

Похожие вопросы

Карта сайта