Class K3aEmbedded

java.lang.Object
no.shhsoft.k3aembedded.K3aEmbedded

public final class K3aEmbedded extends Object
A class that will run a Kafka broker, and optionally a ZooKeeper in the current VM. May be used for testing Kafka integration.
  • Method Details

    • start

      public void start()
      Starts the Kafka broker according to specification from the Builder. If KRaft mode is disabled, also starts a ZooKeeper.
    • stop

      public void stop()
      Stops the running Kafka broker (and ZooKeeper, if enabled).
    • getBrokerPort

      public int getBrokerPort()
      Returns:
      the port the broker listener is bound to
    • getControllerPort

      public int getControllerPort()
      Returns:
      the port the controller listener is bound to
    • getZooKeeperPort

      public int getZooKeeperPort()
      Returns:
      the port the ZooKeeper listens to
    • getAdditionalPort

      public int getAdditionalPort(int portIndex)
      Determines the real port value for one of the additional, random ports allocated through Builder.additionalPorts.
      Parameters:
      portIndex - the index into the additional ports array (0 to additionalPorts - 1)
      Returns:
      the actual port
    • getBootstrapServers

      public String getBootstrapServers()
      Returns:
      the boostrap servers string clients are supposed to use when connecting to the default broker listener
    • getBootstrapServersForAdditionalPort

      public String getBootstrapServersForAdditionalPort(int portIndex)
      Determines the bootstrap server string for one of the additional listeners.
      Parameters:
      portIndex - the index into the additional ports array (0 to additionalPorts - 1)
      Returns:
      the boostrap servers string clients are supposed to use when connecting to the listener on the given port