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

328 Views Asked by At

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?

2

There are 2 best solutions below

1
Ranjith Bokkala On

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() {
   // ...
 }
0
David Levin On

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