org.springframework.batch.item.kafka.builder

## Class KafkaItemWriterBuilder<K,V>

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

-     public class KafkaItemWriterBuilder<K,V>
      extends java.lang.Object

  A builder implementation for the `KafkaItemWriter`
  Since:
    4.2
  Author:
    Mathieu Ouellet, Mahmoud Ben Hassine

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `KafkaItemWriterBuilder()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `KafkaItemWriter<K,V>` | `build()` Validates and builds a `KafkaItemWriter`.
    `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.
    `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.
    `KafkaItemWriterBuilder<K,V>` | `kafkaTemplate(org.springframework.kafka.core.KafkaTemplate<K,V> kafkaTemplate)` Establish the KafkaTemplate to be used by the KafkaItemWriter.
    `KafkaItemWriterBuilder<K,V>` | `timeout(long timeout)` The time limit to wait when flushing items to Kafka.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### KafkaItemWriterBuilder

          public KafkaItemWriterBuilder()

  - ### Method Detail

    - #### 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:
        `KafkaItemWriter.setKafkaTemplate(KafkaTemplate)`

    - #### 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:
        `KeyValueItemWriter.setItemKeyMapper(Converter)`

    - #### 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:
        `KeyValueItemWriter.setDelete(boolean)`

    - #### 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:
        `KafkaItemWriter.setTimeout(long)`

    - #### build

          public KafkaItemWriter<K,V> build()

      Validates and builds a `KafkaItemWriter`.
      Returns:
        a `KafkaItemWriter`