Package com.bakdata.kafka
Class KafkaTestClient
java.lang.Object
com.bakdata.kafka.KafkaTestClient
Client that supports communication with Kafka clusters in test setups, including topic management, reading from
and sending to topics.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadmin()
Create a newAdminClientX
for the clustervoid
createTopic
(String topicName) Creates a new Kafka topic with default settings.void
createTopic
(String topicName, TopicSettings settings) Creates a new Kafka topic with the specified settings.void
createTopic
(String topicName, TopicSettings settings, Map<String, String> config) Creates a new Kafka topic with the specified settings.Create a newTopicSettings.TopicSettingsBuilder
which uses a single partition and no replicasboolean
existsTopic
(String topicName) Checks whether a Kafka topic exists.<K,
V> ReaderBuilder<K, V> read()
Prepare reading data from the cluster.<K,
V> SenderBuilder<K, V> send()
Prepare sending new data to the cluster
-
Constructor Details
-
KafkaTestClient
-
-
Method Details
-
defaultTopicSettings
Create a newTopicSettings.TopicSettingsBuilder
which uses a single partition and no replicas- Returns:
- default topic settings
-
send
Prepare sending new data to the cluster- Returns:
- configured
SenderBuilder
-
read
Prepare reading data from the cluster.ConsumerConfig.AUTO_OFFSET_RESET_CONFIG
is configured toAutoOffsetResetStrategy.EARLIEST
- Returns:
- configured
ReaderBuilder
-
admin
Create a newAdminClientX
for the cluster- Returns:
- configured admin client
-
createTopic
Creates a new Kafka topic with the specified settings.- Parameters:
topicName
- the topic namesettings
- settings for number of partitions and replicationFactorconfig
- topic configuration
-
createTopic
Creates a new Kafka topic with the specified settings. No configs are used.- Parameters:
topicName
- the topic namesettings
- settings for number of partitions and replicationFactor- See Also:
-
createTopic
Creates a new Kafka topic with default settings.- Parameters:
topicName
- the topic name- See Also:
-
existsTopic
Checks whether a Kafka topic exists.- Parameters:
topicName
- the topic name- Returns:
- whether a Kafka topic with the specified name exists or not
-