All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.debezium.testing.testcontainers.DebeziumKafkaContainer Maven / Gradle / Ivy

There is a newer version: 3.0.2.Final
Show newest version
/*
 * Copyright Debezium Authors.
 *
 * Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
 */
package io.debezium.testing.testcontainers;

import org.testcontainers.containers.KafkaContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.utility.DockerImageName;

public class DebeziumKafkaContainer {
    private static final String defaultImage = "confluentinc/cp-kafka:7.2.10";

    public static KafkaContainer defaultKRaftContainer(Network network) {
        try (
                KafkaContainer kafka = new KafkaContainer(DockerImageName.parse(defaultImage))
                        .withNetwork(network)
                        .withKraft()) {
            return kafka;
        }
        catch (Exception e) {
            throw new RuntimeException("Cannot create KRaftContainer with default image.", e);
        }
    }

    public static KafkaContainer defaultKafkaContainer(Network network) {
        try (
                KafkaContainer kafka = new KafkaContainer(DockerImageName.parse(defaultImage))
                        .withNetwork(network)) {
            return kafka;
        }
        catch (Exception e) {
            throw new RuntimeException("Cannot create KafkaContainer with default image.", e);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy