[Apache Curator Tip] Running Embedded Zookeeper Server

Running an Embedded Zookeeper Server for testing is a common need. Apache Curator makes it easy like a walk in the park.


Add following dependencies in pom.xml


Let’s see how to start the Server

public class ZkTestServers {

  TestingServer zkServer;
  public void startzkServer(int port) throws Exception {
    zkServer = new TestingServer(port);  
  public void stopZkServer() throws IOException {

TestServer is the Curator class that does the job. We need to create an instance of it, passing the port. There are additional constructors available for use. The Zookeeper server is started, as the instance is created.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.