Spring Boot和Togglz:捕获功能激活时间并在功能激活时执行一些操作

时间:2019-11-15 05:57:18

标签: java spring-boot togglz

我的Spring Boot应用程序中具有功能Togglz。目前有一些功能可以成功使用。因此,现在我需要在我的一项功能被激活时立即进行一些操作。 有什么办法吗?

2 个答案:

答案 0 :(得分:0)

通过使用Spring Scheduling,您可以解决问题。

第1步:在类级别为此注释@EnableScheduling启用计划

第2步:您可以使用任何模式,例如每小时,分钟,固定延迟等。

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

答案 1 :(得分:0)

我将实现Custom ActivationStrategy并在其中调用您的方法。 示例如何在toggz文档中进行操作:https://www.togglz.org/documentation/activation-strategies.html

相关问题