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

io.microsphere.spring.test.kafka.embedded.EmbeddedKafkaHolder Maven / Gradle / Ivy

There is a newer version: 0.0.3
Show newest version
package io.microsphere.spring.test.kafka.embedded;

import org.apache.kafka.common.KafkaException;
import org.springframework.kafka.test.rule.EmbeddedKafkaRule;

/**
 * @author Mercy
 * @see EmbeddedKafkaHolder
 * @since 1.0.0
 */
public final class EmbeddedKafkaHolder {

    private static EmbeddedKafkaRule embeddedKafka = new EmbeddedKafkaRule(1, false);

    private static boolean started;

    private EmbeddedKafkaHolder() {
        super();
    }

    public static EmbeddedKafkaRule getEmbeddedKafka() {
        if (!started) {
            try {
                embeddedKafka.before();
            } catch (Exception e) {
                throw new KafkaException(e);
            }
            started = true;
        }
        return embeddedKafka;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy