org.springframework.batch.item.kafka

## Class KafkaItemWriter<K,T>

- java.lang.Object
- - org.springframework.batch.item.KeyValueItemWriter<K,T>
  - - org.springframework.batch.item.kafka.KafkaItemWriter<K,T>

- All Implemented Interfaces:
    ItemWriter<T>, org.springframework.beans.factory.InitializingBean

      public class KafkaItemWriter<K,T>
      extends KeyValueItemWriter<K,T>

  An `ItemWriter` implementation for Apache Kafka using a `KafkaTemplate` with default topic configured.

  Since:
    4.2
  Author:
    Mathieu Ouellet

- - ### Field Summary

    - ### Fields inherited from class org.springframework.batch.item.KeyValueItemWriter

      `delete, itemKeyMapper`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `KafkaItemWriter()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `init()` afterPropertiesSet() hook
    `void` | `setKafkaTemplate(org.springframework.kafka.core.KafkaTemplate<K,T> kafkaTemplate)` Set the `KafkaTemplate` to use.
    `protected void` | `writeKeyValue(K key, T value)` Subclasses implement this method to write each item to key value store

    - ### Methods inherited from class org.springframework.batch.item.KeyValueItemWriter

      `afterPropertiesSet, setDelete, setItemKeyMapper, write`

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

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

- - ### Constructor Detail

    - #### KafkaItemWriter

          public KafkaItemWriter()

  - ### Method Detail

    - #### writeKeyValue

          protected void writeKeyValue(K key,
                                       T value)

      Description copied from class: `KeyValueItemWriter`
      Subclasses implement this method to write each item to key value store
      Specified by:
        `writeKeyValue` in class `KeyValueItemWriter<K,T>`
      Parameters:
        `key` - the key
        `value` - the item

    - #### init

          protected void init()

      Description copied from class: `KeyValueItemWriter`
      afterPropertiesSet() hook
      Specified by:
        `init` in class `KeyValueItemWriter<K,T>`

    - #### setKafkaTemplate

          public void setKafkaTemplate(org.springframework.kafka.core.KafkaTemplate<K,T> kafkaTemplate)

      Set the `KafkaTemplate` to use.
      Parameters:
        `kafkaTemplate` - to use