java - Netflix Archaius Dynamic Configuration -
i integrating hystrix in existing project , want read configuration values xml file instead of feeding configuration properties using configuration manager. when values updated in xml file want hystrix configuration updated @ runtime.
this guide following: https://github.com/netflix/archaius/wiki/users-guide
i understand far can use polledconfigurationsource , following code:
polledconfigurationsource source = ... abstractpollingscheduler scheduler = ... dynamicconfiguration configuration = new dynamicconfiguration(source, scheduler); configurationmanager.install(configuration);
how point polledconfigurationsource xml file read properties after fixed time interval?
following code did trick me
private void initializeconfiguration() { // fixeddelaypollingscheduler initialized default system // settings // fixed delay in milliseconds between 2 reads of configuration // urls // archaius.fixeddelaypollingscheduler.delaymills = 60000 // initial delay in milliseconds of reading configuration // source // archaius.fixeddelaypollingscheduler.initialdelaymills = 30000 abstractpollingscheduler scheduler = new fixeddelaypollingscheduler(); // configuration source brings dynamic changes configuration // via polling polledconfigurationsource source = new xmlpolledconfigurationsource(); // configuration polls polledconfigurationsource according // schedule set scheduler dynamicconfiguration configuration = new dynamicconfiguration(source, scheduler); configurationmanager.install(configuration); // registering configuration mbean , accessible // read , update via jconsole configjmxmanager.registerconfigmbean(configuration); }
xmlpolledconfigurationsource source code
public class xmlpolledconfigurationsource implements polledconfigurationsource { @suppresswarnings("static-access") @override public pollresult poll(boolean inital, object checkpoint) throws exception { pollresult pollresult = null; map<string, object> map = new hashmap<>(); // code read content resource return pollresult.createfull(map); } }
Comments
Post a Comment