Package com.bakdata.kafka.consumer
Record Class ConsumerBuilder
java.lang.Object
java.lang.Record
com.bakdata.kafka.consumer.ConsumerBuilder
public record ConsumerBuilder(@NonNull ConsumerTopicConfig topics, @NonNull Map<String,Object> kafkaProperties, @NonNull ConsumerExecutionOptions executionOptions)
extends Record
Provides all runtime configurations when running a
ConsumerApp-
Constructor Summary
ConstructorsConstructorDescriptionConsumerBuilder(@NonNull ConsumerTopicConfig topics, @NonNull Map<String, Object> kafkaProperties, @NonNull ConsumerExecutionOptions executionOptions) Creates an instance of aConsumerBuilderrecord class. -
Method Summary
Modifier and TypeMethodDescriptionCreateAppConfigurationused by this appcom.bakdata.kafka.ConfiguratorCreateConfiguratorto configureSerdeandDeserializerusingkafkaProperties.<K,V> org.apache.kafka.clients.consumer.Consumer<K, V> Create a newConsumerusingkafkaProperties<K,V> org.apache.kafka.clients.consumer.Consumer<K, V> createConsumer(org.apache.kafka.common.serialization.Deserializer<K> keyDeserializer, org.apache.kafka.common.serialization.Deserializer<V> valueDeserializer) Create a newConsumerusingkafkaPropertiesand providedDeserializers<K,V> DefaultConsumerRunnable<K, V> createDefaultConsumerRunnable(org.apache.kafka.clients.consumer.Consumer<K, V> consumer, Consumer<org.apache.kafka.clients.consumer.ConsumerRecords<K, V>> recordProcessor) Creates aDefaultConsumerRunnableusing the provided consumer, processor, andConsumerExecutionOptions.final booleanIndicates whether some other object is "equal to" this one.@NonNull ConsumerExecutionOptionsReturns the value of theexecutionOptionsrecord component.final inthashCode()Returns a hash code value for this object.Returns the value of thekafkaPropertiesrecord component.<K,V> void subscribeToAllTopics(org.apache.kafka.clients.consumer.Consumer<K, V> consumer) Subscribes the givenConsumerto all input topics and patterns configured intopics.@NonNull ConsumerTopicConfigtopics()Returns the value of thetopicsrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
ConsumerBuilder
public ConsumerBuilder(@NonNull @NonNull ConsumerTopicConfig topics, @NonNull @NonNull Map<String, Object> kafkaProperties, @NonNull @NonNull ConsumerExecutionOptions executionOptions) Creates an instance of aConsumerBuilderrecord class.- Parameters:
topics- the value for thetopicsrecord componentkafkaProperties- the value for thekafkaPropertiesrecord componentexecutionOptions- the value for theexecutionOptionsrecord component
-
-
Method Details
-
createConsumer
public <K,V> org.apache.kafka.clients.consumer.Consumer<K,V> createConsumer()Create a newConsumerusingkafkaProperties- Type Parameters:
K- type of keysV- type of values- Returns:
Consumer- See Also:
-
KafkaConsumer(Map)
-
createConsumer
public <K,V> org.apache.kafka.clients.consumer.Consumer<K,V> createConsumer(org.apache.kafka.common.serialization.Deserializer<K> keyDeserializer, org.apache.kafka.common.serialization.Deserializer<V> valueDeserializer) Create a newConsumerusingkafkaPropertiesand providedDeserializers- Type Parameters:
K- type of keysV- type of values- Parameters:
keyDeserializer-Deserializerto use for keysvalueDeserializer-Deserializerto use for values- Returns:
Consumer- See Also:
-
KafkaConsumer(Map, Deserializer, Deserializer)
-
createConfigurator
public com.bakdata.kafka.Configurator createConfigurator()CreateConfiguratorto configureSerdeandDeserializerusingkafkaProperties.- Returns:
Configurator
-
createConfiguration
CreateAppConfigurationused by this app- Returns:
AppConfiguration
-
subscribeToAllTopics
public <K,V> void subscribeToAllTopics(org.apache.kafka.clients.consumer.Consumer<K, V> consumer) Subscribes the givenConsumerto all input topics and patterns configured intopics. This includes all topics fromgetInputTopics(),getLabeledInputTopics(),getInputPattern(), andgetLabeledInputPatterns().- Type Parameters:
K- type of keysV- type of values- Parameters:
consumer-Consumerinstance to subscribe
-
createDefaultConsumerRunnable
public <K,V> DefaultConsumerRunnable<K,V> createDefaultConsumerRunnable(org.apache.kafka.clients.consumer.Consumer<K, V> consumer, Consumer<org.apache.kafka.clients.consumer.ConsumerRecords<K, V>> recordProcessor) Creates aDefaultConsumerRunnableusing the provided consumer, processor, andConsumerExecutionOptions.- Type Parameters:
K- type of keysV- type of values- Parameters:
consumer-Consumerto be used by the runnablerecordProcessor-Consumerto processConsumerRecords- Returns:
- A new
DefaultConsumerRunnableinstance
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
topics
Returns the value of thetopicsrecord component.- Returns:
- the value of the
topicsrecord component
-
kafkaProperties
Returns the value of thekafkaPropertiesrecord component.- Returns:
- the value of the
kafkaPropertiesrecord component
-
executionOptions
Returns the value of theexecutionOptionsrecord component.- Returns:
- the value of the
executionOptionsrecord component
-