Class KafkaItemWriterBuilder<K,V>

java.lang.Object
org.springframework.batch.item.kafka.builder.KafkaItemWriterBuilder<K,V>

public class KafkaItemWriterBuilder<K,V> extends Object
A builder implementation for the KafkaItemWriter
Since:
4.2
Author:
Mathieu Ouellet, Mahmoud Ben Hassine
  • Constructor Details

    • KafkaItemWriterBuilder

      public KafkaItemWriterBuilder()
  • Method Details

    • kafkaTemplate

      public KafkaItemWriterBuilder<K,V> kafkaTemplate(org.springframework.kafka.core.KafkaTemplate<K,V> kafkaTemplate)
      Establish the KafkaTemplate to be used by the KafkaItemWriter.
      Parameters:
      kafkaTemplate - the template to be used
      Returns:
      this instance for method chaining
      See Also:
    • itemKeyMapper

      public KafkaItemWriterBuilder<K,V> itemKeyMapper(org.springframework.core.convert.converter.Converter<V,K> itemKeyMapper)
      Set the Converter to use to derive the key from the item.
      Parameters:
      itemKeyMapper - the Converter to use.
      Returns:
      The current instance of the builder.
      See Also:
    • delete

      public KafkaItemWriterBuilder<K,V> delete(boolean delete)
      Indicate if the items being passed to the writer are all to be sent as delete events to the topic. A delete event is made of a key with a null value. If set to false (default), the items will be sent with provided value and key converter by the itemKeyMapper. If set to true, the items will be sent with the key converter from the value by the itemKeyMapper and a null value.
      Parameters:
      delete - removal indicator.
      Returns:
      The current instance of the builder.
      See Also:
    • timeout

      public KafkaItemWriterBuilder<K,V> timeout(long timeout)
      The time limit to wait when flushing items to Kafka.
      Parameters:
      timeout - milliseconds to wait, defaults to -1 (no timeout).
      Returns:
      The current instance of the builder.
      Since:
      4.3.2
      See Also:
    • build

      public KafkaItemWriter<K,V> build()
      Validates and builds a KafkaItemWriter.
      Returns:
      a KafkaItemWriter