Class ConsumerBuilder

java.lang.Object
com.bakdata.kafka.consumer.ConsumerBuilder

public final class ConsumerBuilder extends Object
Provides all runtime configurations when running a ConsumerApp
See Also:
  • Constructor Details

  • Method Details

    • createConsumer

      public <K, V> org.apache.kafka.clients.consumer.Consumer<K,V> createConsumer()
      Create a new Consumer using kafkaProperties
      Type Parameters:
      K - type of keys
      V - 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 new Consumer using kafkaProperties and provided Deserializer Deserializers. The deserializers will be configured automatically.
      Type Parameters:
      K - type of keys
      V - type of values
      Parameters:
      keyDeserializer - Deserializer to use for keys
      valueDeserializer - Deserializer to use for values
      Returns:
      Consumer
      See Also:
      • KafkaConsumer(Map, Deserializer, Deserializer)
    • createConsumer

      public <K, V> org.apache.kafka.clients.consumer.Consumer<K,V> createConsumer(com.bakdata.kafka.Preconfigured<org.apache.kafka.common.serialization.Deserializer<K>> keyDeserializer, com.bakdata.kafka.Preconfigured<org.apache.kafka.common.serialization.Deserializer<V>> valueDeserializer)
      Create a new Consumer using kafkaProperties and provided Preconfigured deserializers. The preconfiguration will be resolved to yield configured Deserializers that are used to create the new Consumer.
      Type Parameters:
      K - type of keys
      V - type of values
      Parameters:
      keyDeserializer - Preconfigured to use for keys
      valueDeserializer - Preconfigured to use for values
      Returns:
      Consumer
      See Also:
      • KafkaConsumer(Map, Deserializer, Deserializer)
    • createConfigurator

      public com.bakdata.kafka.Configurator createConfigurator()
      Create Configurator to configure Serde and Deserializer using kafkaProperties.
      Returns:
      Configurator
    • createConfiguration

      public AppConfiguration<ConsumerTopicConfig> createConfiguration()
      Create AppConfiguration used by this app
      Returns:
      AppConfiguration
    • subscribeToAllTopics

      public <K, V> void subscribeToAllTopics(org.apache.kafka.clients.consumer.Consumer<K,V> consumer)
      Subscribes the given Consumer to all input topics and patterns configured in topics. This includes all topics from getInputTopics(), getLabeledInputTopics(), getInputPattern(), and getLabeledInputPatterns().
      Type Parameters:
      K - type of keys
      V - type of values
      Parameters:
      consumer - Consumer instance 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 a DefaultConsumerRunnable using the provided consumer, processor, and ConsumerExecutionOptions.
      Type Parameters:
      K - type of keys
      V - type of values
      Parameters:
      consumer - Consumer to be used by the runnable
      recordProcessor - Consumer to process ConsumerRecords
      Returns:
      A new DefaultConsumerRunnable instance
    • getTopics

      @NonNull public @NonNull ConsumerTopicConfig getTopics()
    • getKafkaProperties

      @NonNull public @NonNull Map<String,Object> getKafkaProperties()
    • getExecutionOptions

      @NonNull public @NonNull ConsumerExecutionOptions getExecutionOptions()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object