public class KafkaContainer extends org.testcontainers.containers.GenericContainer<KafkaContainer>
Supported image: confluentinc/cp-kafka
Exposed ports:
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
DEFAULT_CLUSTER_ID |
protected java.lang.String |
externalZookeeperConnect |
static int |
KAFKA_PORT |
static int |
ZOOKEEPER_PORT |
| Constructor and Description |
|---|
KafkaContainer()
Deprecated.
use
KafkaContainer(DockerImageName) instead |
KafkaContainer(org.testcontainers.utility.DockerImageName dockerImageName) |
KafkaContainer(java.lang.String confluentPlatformVersion)
Deprecated.
use
KafkaContainer(DockerImageName) instead |
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.String |
brokerAdvertisedListener(com.github.dockerjava.api.command.InspectContainerResponse containerInfo) |
protected java.lang.String |
commandKraft() |
protected java.lang.String |
commandZookeeper() |
protected void |
configure() |
protected void |
configureKraft() |
protected void |
configureZookeeper() |
protected void |
containerIsStarting(com.github.dockerjava.api.command.InspectContainerResponse containerInfo) |
java.lang.String |
getBootstrapServers() |
KafkaContainer |
withClusterId(java.lang.String clusterId) |
KafkaContainer |
withEmbeddedZookeeper() |
KafkaContainer |
withExternalZookeeper(java.lang.String connectString) |
KafkaContainer |
withKraft() |
KafkaContainer |
withListener(java.util.function.Supplier<java.lang.String> listenerSupplier)
Add a
Supplier that will provide a listener with format host:port. |
addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, apply, canBeReused, containerIsCreated, containerIsStarted, containerIsStarted, containerIsStarting, containerIsStopped, containerIsStopping, copyFileFromContainer, createVolumeDirectory, dependsOn, dependsOn, dependsOn, doStart, equals, failed, finished, getBinds, getCommandParts, getContainerId, getContainerInfo, getContainerName, getCopyToFileContainerPathMap, getCreateContainerCmdModifiers, getDependencies, getDockerClient, getDockerImageName, getEnv, getEnvMap, getExposedPorts, getExtraHosts, getImage, getIpAddress, getLabels, getLinkedContainers, getLivenessCheckPort, getLivenessCheckPortNumbers, getLivenessCheckPorts, getLogConsumers, getNetwork, getNetworkAliases, getNetworkMode, getPortBindings, getShmSize, getStartupAttempts, getStartupCheckStrategy, getTestHostIpAddress, getTmpFsMapping, getVolumesFroms, getWaitStrategy, getWorkingDirectory, hashCode, isHostAccessible, isPrivilegedMode, isShouldBeReused, logger, setBinds, setCommand, setCommand, setCommandParts, setContainerDef, setCopyToFileContainerPathMap, setDockerImageName, setEnv, setExposedPorts, setExtraHosts, setHostAccessible, setImage, setLabels, setLinkedContainers, setLogConsumers, setNetwork, setNetworkAliases, setNetworkMode, setPortBindings, setPrivilegedMode, setShmSize, setStartupAttempts, setStartupCheckStrategy, setTmpFsMapping, setVolumesFroms, setWaitStrategy, setWorkingDirectory, start, starting, stop, succeeded, toString, waitingFor, waitUntilContainerStarted, withAccessToHost, withClasspathResourceMapping, withClasspathResourceMapping, withCommand, withCommand, withCopyFileToContainer, withCopyToContainer, withCreateContainerCmdModifier, withEnv, withEnv, withExposedPorts, withExtraHost, withFileSystemBind, withImagePullPolicy, withLabel, withLabels, withLogConsumer, withMinimumRunningDuration, withNetwork, withNetworkAliases, withNetworkMode, withPrivilegedMode, withReuse, withSharedMemorySize, withStartupAttempts, withStartupCheckStrategy, withStartupTimeout, withTmpFs, withVolumesFrom, withWorkingDirectoryclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddFileSystemBind, followOutput, followOutput, self, withEnv, withFileSystemBindcopyFileFromContainer, copyFileToContainer, copyFileToContainer, execInContainer, execInContainer, execInContainerWithUser, execInContainerWithUser, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunningpublic static final int KAFKA_PORT
public static final int ZOOKEEPER_PORT
public static final java.lang.String DEFAULT_CLUSTER_ID
protected java.lang.String externalZookeeperConnect
@Deprecated public KafkaContainer()
KafkaContainer(DockerImageName) instead@Deprecated public KafkaContainer(java.lang.String confluentPlatformVersion)
KafkaContainer(DockerImageName) insteadpublic KafkaContainer(org.testcontainers.utility.DockerImageName dockerImageName)
public KafkaContainer withEmbeddedZookeeper()
public KafkaContainer withExternalZookeeper(java.lang.String connectString)
public KafkaContainer withKraft()
public KafkaContainer withClusterId(java.lang.String clusterId)
public java.lang.String getBootstrapServers()
protected void configure()
configure in class org.testcontainers.containers.GenericContainer<KafkaContainer>protected void configureKraft()
protected void configureZookeeper()
protected void containerIsStarting(com.github.dockerjava.api.command.InspectContainerResponse containerInfo)
containerIsStarting in class org.testcontainers.containers.GenericContainer<KafkaContainer>protected java.lang.String commandKraft()
protected java.lang.String commandZookeeper()
public KafkaContainer withListener(java.util.function.Supplier<java.lang.String> listenerSupplier)
Supplier that will provide a listener with format host:port.
Host will be added as a network alias.
The listener will be added to the list of default listeners.
Default listeners:
Default advertised listeners:
container.getHost():container.getMappedPort(9093)container.getConfig().getHostName():9092listenerSupplier - a supplier that will provide a listenerKafkaContainer instanceprotected java.lang.String brokerAdvertisedListener(com.github.dockerjava.api.command.InspectContainerResponse containerInfo)