I have two application - api
and dashboard
. Both of these applications use the same Features from the same database. Togglz console is only active in dashboard
application. The issue is that when I change the state of the feature in my dashboard
application, api
application is not immediately aware about that. I need to restart my api
in order to refresh the features state.
Is it possible to notify api
application about changes of feature state without restarting?
UPDATED - Togglz configuration added
This is the a base configuration in my Maven common
project(api
and dashboard
projects depend on this one):
@Configuration
public class FeatureToggleConfiguration {
@Autowired
private DataSource dataSource;
@Bean
public FeatureManager getFeatureManager() {
// @formatter:off
FeatureManager featureManager = new FeatureManagerBuilder()
.stateRepository(new CachingStateRepository(new JDBCStateRepository(dataSource)))
.featureEnum(ApplicationFeatures.class)
.userProvider(new SpringSecurityUserProvider(Authority.Type.ROLE_ADMIN.getName()))
.build();
// @formatter:on
return featureManager;
}
}
ApplicationFeatures
(also placed in common
project):
public enum ApplicationFeatures implements Feature {
// @formatter:off
@EnabledByDefault
@Label("Log Events Feature")
LOG_EVENT_FEATURE,
@EnabledByDefault
@Label("Log Ok Sessions Feature")
LOG_OK_SESSIONS_FEATURE,
@EnabledByDefault
@Label("Log HTTP Requests Data Feature")
LOG_HTTP_REQUESTS_DATA_FEATURE;
// @formatter:on
public boolean isActive() {
return FeatureContext.getFeatureManager().isActive(this);
}
}
This is DashboardFeatureToggleConfiguration
(for Togglz web console) from my dashboard
project:
@Configuration
public class DashboardFeatureToggleConfiguration {
@Bean
public ServletRegistrationBean getTogglzConsole() {
ServletRegistrationBean servlet = new ServletRegistrationBean();
servlet.setName("TogglzConsole");
servlet.setServlet(new TogglzConsoleServlet());
servlet.setUrlMappings(Collections.singletonList("/togglz/*"));
return servlet;
}
}