Closed evgeniy2702 closed 1 year ago
The spring boot starter registers any bots found in the injection context by itself, so you have two instances is the bot running if you register it yourself as well
The spring boot starter registers any bots found in the injection context by itself, so you have two instances is the bot running if you register it yourself as well
Thank you so much for your feedback. I broked my head trying to figure out what the cause is. And I should have figured out the dependencies.
Hy everyone. I have this error when I use a Telegram bot extending from LongPollingTelegram. I am sure that i have only one instance of my bot in work. My bot is written in SpringBoot version 2.6.4, java version 1.8.0_271, which is deployed on tomcat version 9.0.56 under linux. I used the following dependencies for the Telegram bot : `
I use the following code to initialize my bot :
@EventListener({ContextRefreshedEvent.class}) public void init() throws TelegramApiException{ consoleLogger.info("Start initializer MediaBot ."); TelegramBotsApi telegramBotsApi = new TelegramBotsApi(DefaultBotSession.class); try{ BotSession session = telegramBotsApi.registerBot(bot); bot.setSession(session); } catch (TelegramApiException e) { consoleLogger.error("Error occurred: " + e.getMessage()); } }
And my bean of bot has the following PreDestroy method to close and release all resources:
@PreDestroy public void preDestroy(){ consoleLogger.info("Stop bots session ."); this.onClosing(); this.getSession().stop(); consoleLogger.error("Bot session was stopped ."); }
But when I deploy my bot from tomcat, I get the following error :
And this error repeats every second. BUT the most interesting thing is that my bot still partially works after undeploying. So, what am I doing wrong? I can't figure it out. The support of Telegram is not answer for my email.