Spring Cloud Zookeeper

Spring Cloud Zookeeper provides Apache Zookeeper integrations for Spring Boot apps through autoconfiguration and binding to the Spring Environment and other Spring programming model idioms. With a few simple annotations you can quickly enable and configure the common patterns inside your application and build large distributed systems with Zookeeper. The patterns provided include Service Discovery and Distributed Configuration.

Quick Start
Fork me on GitHub

Features

Spring Cloud Zookeeper features:

  • Service Discovery: instances can be registered with Zookeeper and clients can discover the instances using Spring-managed beans
  • Supports Ribbon, the client side load-balancer via Spring Cloud Netflix
  • Supports Zuul, a dynamic router and filter via Spring Cloud Netflix
  • Distributed Configuration: using Zookeeper as a data store

Quick Start

Download

The recommended way to get started using spring-cloud-zookeeper in your project is with a dependency management system – the snippet below can be copied and pasted into your build. Need help? See our getting started guides on building with Maven and Gradle.

As long as Spring Cloud Zookeeper, Apache Curator and the Zookeeper Java Client are on the classpath any Spring Boot application with @EnableDiscoveryClient will try to contact a Zookeeper agent on localhost:2181 (the default value of zookeeper.connectString).

@Configuration
@EnableAutoConfiguration
@EnableDiscoveryClient
@RestController
public class Application {

  @RequestMapping("/")
  public String home() {
    return "Hello World";
  }

  public static void main(String[] args) {
    SpringApplication.run(Application.class, args);
  }

}

A local Zookeeper server must be running. See the Zookeeper documentation on how to run a Zookeeper server.

Sample Projects