简体   繁体   中英

Spring Boot and Togglz: Catching feature activation time and do some action when feature became active

I have feature togglz in my spring boot application. There are some features which are successfully work for the moment. So now I need to do some operation right in the time when one of my feature is activated. Is there any way to do that?

By using Spring Scheduling you can resolve your problem.

step 1: Enable scheduling for this annotation @EnableScheduling at class level

step 2: You can use any pattern like, hourly, minute, fixed delay,..etc.

@Scheduled(fixedRate = 10000)
@Scheduled(cron = "0 * * * * MON-FRI")`enter code here`
void checTogglzk() {
   // ...
 }

I would implement Custom ActivationStrategy and call your method within it. Example how to do it in toggz doc:https://www.togglz.org/documentation/activation-strategies.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM