...
You can use CbsClientFactory to lookup for CBS in your application. Returned CbsClient can then be used to get a configuration, poll for configuration or poll for configuration changes.
Sample usage:
Code Block | ||
---|---|---|
| ||
// Generate RequestID and InvocationID which will be used when logging and in HTTP requests |
...
RequestDiagnosticContext diagnosticContext = RequestDiagnosticContext.create(); |
...
// Read necessary properties from the environment |
...
final EnvProperties env = EnvProperties.fromEnvironment(); |
...
// Create the client and use it to get the configuration |
...
CbsClientFactory.createCbsClient(env) |
...
.flatMap(cbsClient -> cbsClient.get(diagnosticContext)) |
...
.subscribe(jsonObject -> { |
...
// do a stuff with your JSON configuration using GSON API |
...
final int port = Integer.parseInt(jsonObject.get("collector.listen_port").getAsString()); |
...
// ... |
...
}); |
Notes about reactive programming
...