You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I use telegrambots-spring-boot-starter to build Telegram bots and it feels odd that under the hood the library uses JDK's ScheduledExecutorService instead of Spring's TaskScheduler for scheduling.
Unlike ScheduledExecutorService, TaskScheduler is a managed bean created by Spring Boot automatically. And if I want to make ScheduledExecutorService manageable, I need to register a bean manually since TaskScheduler and ScheduledExecutorService are not interchangeable. This is not what I'm expecting from a *starter library.
Describe the solution you'd like
I would expect telegrambots-longpolling to introduce an interface like:
This way, Spring-based apps can use autoconfigured TaskScheduler for scheduling, and non-Spring apps can either use vanilla ScheduledExecutorService or even provide own implementations of TelegramLongPollingBotScheduler!
Describe alternatives you've considered
Technically it's possible to adapt TaskScheduler interface to ScheduledExecutorService directly using delegate pattern, however it wouldn't be as smooth as dedicated TelegramLongPollingBotScheduler interface, since we need a single method only for scheduling.
Is your feature request related to a problem? Please describe.
I use
telegrambots-spring-boot-starterto build Telegram bots and it feels odd that under the hood the library uses JDK'sScheduledExecutorServiceinstead of Spring's TaskScheduler for scheduling.Unlike
ScheduledExecutorService,TaskScheduleris a managed bean created by Spring Boot automatically. And if I want to makeScheduledExecutorServicemanageable, I need to register a bean manually sinceTaskSchedulerandScheduledExecutorServiceare not interchangeable. This is not what I'm expecting from a*starterlibrary.Describe the solution you'd like
I would expect
telegrambots-longpollingto introduce an interface like:with the default implementation:
Then we would refer to
TelegramLongPollingBotSchedulerinstead ofScheduledExecutorServiceamong the code.Finally, I would expect
telegrambots-spring-boot-starterto introduce another implementation and use it as default:This way, Spring-based apps can use autoconfigured
TaskSchedulerfor scheduling, and non-Spring apps can either use vanillaScheduledExecutorServiceor even provide own implementations ofTelegramLongPollingBotScheduler!Describe alternatives you've considered
Technically it's possible to adapt
TaskSchedulerinterface toScheduledExecutorServicedirectly using delegate pattern, however it wouldn't be as smooth as dedicatedTelegramLongPollingBotSchedulerinterface, since we need a single method only for scheduling.Additional context
TelegramLongPollingBotSchedulercould resolve a part oftelegrambots-springboot-longpolling-starter: Java process never stops afterSpringApplication.exitis called #1513 discussion.while (running) {}be enough?