io.microsphere.spring.test.kafka.embedded.EmbeddedKafkaHolder Maven / Gradle / Ivy
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;
}
}