B4J Question Receive more than one message at a time in a bot with the jtelegram library

Yoldi

Member
Greetings.

If multiple messages are received at the same time in a bot
(with the jtelegram library)
how can I process all messages without losing any.

Now I use the event JTB_onMessageReceived,
but I lose messages.

Thanks in advance
 

DonManfred

Expert
Licensed User
Longtime User
Please post more acurat questions. There are multiple Libraries available. Which one are you using?

If you are using my wrapper then read the following answer: (ignore it if you are using another library)

The bot is, as its name is suggesting, designed to run all the time. When the bot is running all messages coming in are raised in an Event. I never heard of any Problems.

If the bot is not running and someone sends a message to him; i´m not sure if they are suspect to survive in the Telegram network. You probably loose them if your bot is not running.
 
Upvote 0

Yoldi

Member
Greetings.
If I am using your library.

what the bot basically does is that when it receives a message it makes a query to a database and sends the response.

The disadvantage that I have observed is that when for some reason I have to restart the bot and then several messages enter, only one processes and the rest do not, although I see them in the log.

Thank you

1585493686360.png
 
Upvote 0

behnam_tr

Active Member
Licensed User
Longtime User
Our friend means that.....

when recive Several message at same time with jtelegrambot lib
while excuting JTB_onMessageReceived for first message and still not finished
we cant recive other messages
In fact, messages are receive one by one

We want messages to be received in parallel like php, not serialized and one by one

it possible run every message in other thread?
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
what the bot basically does is that when it receives a message it makes a query to a database and sends the response.
You can store the incoming message in a FIFO list to process them later by a timer or whatever.
In fact, messages are receive one by one
Because it is one bot which is running. True
We want messages to be received in parallel like php, not serialized and one by one
You can not start multiple Bots
it possible run every message in other thread?
No. the problem is in your app. You need to get around it. See my comment above. Use a FIFO List and process them later.
 
Last edited:
Upvote 0
Top