Package no.shhsoft.k3aembedded
Class K3aEmbedded
java.lang.Object
no.shhsoft.k3aembedded.K3aEmbedded
A class that will run a Kafka broker, and optionally a ZooKeeper in
the current VM. May be used for testing Kafka integration.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceImplementors of this interface may provide additional broker configuration.static final classBuilder forK3aEmbeddedinstances. -
Method Summary
Modifier and TypeMethodDescriptionintgetAdditionalPort(int portIndex) Determines the real port value for one of the additional, random ports allocated throughBuilder.additionalPorts.getBootstrapServersForAdditionalPort(int portIndex) Determines the bootstrap server string for one of the additional listeners.intintintvoidstart()Starts the Kafka broker according to specification from theBuilder.voidstop()Stops the running Kafka broker (and ZooKeeper, if enabled).
-
Method Details
-
start
public void start()Starts the Kafka broker according to specification from theBuilder. 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 throughBuilder.additionalPorts.- Parameters:
portIndex- the index into the additional ports array (0toadditionalPorts - 1)- Returns:
- the actual port
-
getBootstrapServers
- Returns:
- the boostrap servers string clients are supposed to use when connecting to the default broker listener
-
getBootstrapServersForAdditionalPort
Determines the bootstrap server string for one of the additional listeners.- Parameters:
portIndex- the index into the additional ports array (0toadditionalPorts - 1)- Returns:
- the boostrap servers string clients are supposed to use when connecting to the listener on the given port
-