Spring Boot : Getting @Scheduled cron value from database

前端 未结 4 1693
再見小時候
再見小時候 2020-12-09 09:16

I\'m using Spring Boot and have issues scheduling a cron task using values existing in database.

For the time being, I\'m reading values f

4条回答
  •  不思量自难忘°
    2020-12-09 09:48

    To achieve your goals you must configure your scheduler at runtime. It means you need to use more low-level scheduler API. Precisely when you have already prepared connect with your database you can configure your scheduler. I think you need to get rid of using @Scheduled annotation and manully manage your scheduler.

    I think these topics can help to describe what I mean:

    1. How to change Spring's @Scheduled fixedDelay at runtime

    2. Scheduling a job with Spring programmatically (with fixedRate set dynamically)

    However always you can use wild approaches where you would intercept the bean creation and replace original annotation on annotation with custom metadata but in order to implement it you must know many framework details and how @Scheduled annatation processor works.

提交回复
热议问题