Switch branches/tags
Nothing to show
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Vertx Configuration via Zookeeper

This example uses docker-compose to setup a 5 server Zookeeper service, 3 vert.x web servers, and one service that periodically sends updates to a Zookeeper path for the vert.x web servers.

You might find the docker-compose.yml, Dockerfile.zookeeper, zoo.cfg, and zookeeper-entrypoint.sh files to be useful in other projects where you want to quickly setup a Zookeeper service as the instructions for many of the docker images for Zookeeper are not very robust.

Table of contents



  • ConfigurationGenerator.java - Generates "configrations" and loads them into Zookeeper periodically
  • Constants.java - constants for the connection string and path in Zookeeper
  • SimpleWebsiteMain.java - An example of the vert.x website that does not watch for updated "configs" in Zookeeper
  • WebsiteMain.java - The vert.x website that does get updated "configs"
  • ZookeeperVerticle.java - The vert.x Verticle(Service) that watches Zookeeper for configuration updates.


This example requires docker version 1.11+ and docker-compose version 1.6+.

The directory is already set up for eclipse neon if you "Open Projects From Filesystem..."


mvn package

If you do not have maven installed, you can build using docker:

mkdir .m2
docker run -it \
           --rm \
           --name maven-build \
           -v "$PWD":/usr/src/myproject \
           -v "$PWD"/.m2:/root/.m2 \
           -w /usr/src/myproject \
       maven:3-jdk-8 mvn package
  1. run in a docker image using an interactive pseudo-tty
  2. removing the container on exit
  3. name the container "maven-build"
  4. bind the current directory to a location inside the container so the build result can be saved outside the container
  5. bind the .m2 directory to the container's maven repository location so we only download the jars needed once to not waste network resources
  6. set the working directory in the container to the current directory outside the container
  7. Use a maven jdk-8 image and run maven to package a jar.

Running and Screenshots

docker-compose up


You can now monitor the app in your terminal and use,, and to see the three webservers serve the latest configuration.

Other Operating Systems

docker-machine ip

You can now monitor the app in your terminal and use docker-machine-ip:8080, docker-machine-ip:8081, and docker-machine-ip:8082 to see the three webservers serve the latest configuration.

running zkcli

docker-compose run --rm zkcli -server zookeeper3

The Terminal:


The Browser Result:


Pressing ctrl-c will should stop docker-compose but I would also recommend using docker-compose down before calling docker-compose a second time.

You can also test Zookeeper a bit by killing some of the zookeeper containers and seeing how the app responds.