Package com.github.charithe.kafka
Class EphemeralKafkaCluster
java.lang.Object
com.github.charithe.kafka.EphemeralKafkaCluster
- All Implemented Interfaces:
AutoCloseable
-
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Create a minimal consumer configuration with auto commit enabled.consumerConfig(boolean enableAutoCommit) Create a minimal consumer configuration.static EphemeralKafkaClustercreate(int numBroker) Create a new ephemeral Kafka clusterstatic EphemeralKafkaClustercreate(int numBroker, int zookeeperPort) Create a new ephemeral Kafka cluster with the specified Zookeeper portstatic EphemeralKafkaClustercreate(int numBroker, int zookeeperPort, Properties brokerProperties) Create a new ephemeral Kafka cluster with the specified Zookeeper port and broker propertiesvoidcreateTopics(String... topics) booleanbooleanCreate a minimal producer configuration that can be used to produce to this brokervoidstop()
-
Method Details
-
create
Create a new ephemeral Kafka cluster- Parameters:
numBroker- number of brokers- Returns:
- EphemeralKafkaCluster
- Throws:
Exception- if create fails
-
create
Create a new ephemeral Kafka cluster with the specified Zookeeper port- Parameters:
numBroker- Number of brokerszookeeperPort- Port the Zookeeper should listen on- Returns:
- EphemeralKafkaCluster
- Throws:
Exception- if create fails
-
create
public static EphemeralKafkaCluster create(int numBroker, int zookeeperPort, Properties brokerProperties) throws Exception Create a new ephemeral Kafka cluster with the specified Zookeeper port and broker properties- Parameters:
numBroker- Number of brokerszookeeperPort- Port the Zookeeper should listen onbrokerProperties- Override properties for all brokers in the cluster- Returns:
- EphemeralKafkaCluster
- Throws:
Exception- if create fails
-
isHealthy
public boolean isHealthy() -
isRunning
public boolean isRunning() -
stop
-
getBrokers
-
connectionString
-
producerConfig
Create a minimal producer configuration that can be used to produce to this broker- Returns:
- Properties
-
consumerConfig
Create a minimal consumer configuration with auto commit enabled. Offset is set to "earliest".- Returns:
- Properies
-
consumerConfig
Create a minimal consumer configuration. Offset is set to "earliest".- Parameters:
enableAutoCommit- Enable auto commit- Returns:
- Properties
-
createTopics
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-