Apache ZooKeeper is a centralized service for maintaining configuration information, naming, providing distributed synchronization, and providing group services. It is used as a cluster coordination service for demanding systems such as Hadoop, Kafka, Storm, Akka, Neo4j, Talend ESB and so on.

ZooKeeper is a very versatile tool and a perfect partner for a microservice architecture. These are its most common uses:

  • Centralized configuration
  • Service discovery
  • Resource allocation
  • Failure detection
  • Leader election for failover scenarios
  • High priority queues

I have started using ZooKeeper as a configuration repository for a spring-boot application. I have found it extremelly simple thanks to Apache Curator and Spring Cloud Config.

Spring Cloud ZooKeeper Config has a specific Spring PropertySource that loads transparently the configuration properties from ZooKeeper. It enables me to switch the source of my properties without affecting my application.

The source code of this example is here


public class SampleSimpleApplication {
    // Simple example shows how a command line spring application can execute an
    // injected bean service. Also demonstrates how you can use @Value to inject
    private HelloWorldService helloWorldService;
    public void run() {
    public static void main(String[] args) throws Exception {
        SpringApplication.run(SampleSimpleApplication.class, args);


public class HelloWorldService {
	private String name;
	public String getHelloMessage() {
		return "Hello " + this.name;


# name=James

Loading properties in ZooKeeper

create /config "
create /config/myapplication "
create /config/myapplication/name Mark

All in action