Over a million developers have joined DZone.

Library for Configuration Management From Netflix

DZone 's Guide to

Library for Configuration Management From Netflix

Archaius is the library that is used by all of the Netflix OSS components for configuration, and it is an extension of the Apache Commons Configuration project.

· DevOps Zone ·
Free Resource

Archaius is the Netflix client side configuration library. It is the library that is used by all of the Netflix OSS components for configuration, and it is an extension of the Apache Commons Configuration project. It also allows updates to configure by either polling a source for changes or allowing for a source to push changes to the client. Additionally, Archaius uses Dynamic Property classes as handles to properties.

Some Archaius features include the following: 

  • Dynamic, typed properties.
  • High throughput and threadsafe configuration operations.
  • A polling framework that allows for the obtainment property changes of a configuration source.
  • A callback mechanism that gets invoked on effective.
  • A JMX MBean that can be accessed via JConsole to inspect and invoke operations on properties.
  • Out of the box, composite configurations for applications.
  • Implementations of dynamic configuration sources for URLs, JDBC and Amazon DynamoDB.
  • Scala dynamic property wrappers.

In my sample, I will be showing you how to use the Dynamic Properties and how it is able to be used Archaius with configuration with many environments.

About ArchaiusSandBox class:

  • Set default configuration with property archaius.properties.
  • InstallConfig is a method that apply the config, with polling to each one second.
  • In a set environment, we will get value from "environment" variable, we expected in this case DEV or TEST
  • In the main method, we call the configuration to get "myprop".
    • It is possible to put default configuration to property. I defined "NOT FOUND", but it is possible put any value.
    • Wait 10 seconds to put the new configuration and call again.

Resources folder. There are three properties:

  1. archaius.properties is the default configuration with  reference to configuration available per environment.

  2. archaius-dev.properties configuration specific to DEV.
  3. archaius-test configuration specific to TEST.

In runtime, it is possible to change property. Work in this sample should be added on archaius.properties (within 10 seconds) to the property myprop=TEST-VALUE. After 10 seconds, put in the main method. It should print the new value.

In this post, I used some Archaius functionalities. There are many others also available, but with these few codes, it is possible to create a configuration to many environments with the possibility to change in the runtime.

Here is my sample.

cloud ,devops ,netflix ,configuration management

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}