org.springframework.batch.item.kafka.builder

## Class KafkaItemReaderBuilder<K,V>

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

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

  A builder implementation for the `KafkaItemReader`.
  Since:
    4.2
  Author:
    Mathieu Ouellet, Mahmoud Ben Hassine
  See Also:
    `KafkaItemReader`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `KafkaItemReaderBuilder()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `KafkaItemReader<K,V>` | `build()`
    `KafkaItemReaderBuilder<K,V>` | `consumerProperties(java.util.Properties consumerProperties)` Configure the underlying consumer properties.
    `KafkaItemReaderBuilder<K,V>` | `name(java.lang.String name)` The name used to calculate the key within the `ExecutionContext`.
    `KafkaItemReaderBuilder<K,V>` | `partitions(java.lang.Integer... partitions)` A list of partitions to manually assign to the consumer.
    `KafkaItemReaderBuilder<K,V>` | `partitions(java.util.List<java.lang.Integer> partitions)` A list of partitions to manually assign to the consumer.
    `KafkaItemReaderBuilder<K,V>` | `pollTimeout(java.time.Duration pollTimeout)` Set the pollTimeout for the poll() operations.
    `KafkaItemReaderBuilder<K,V>` | `saveState(boolean saveState)` Configure if the state of the `ItemStreamSupport` should be persisted within the `ExecutionContext` for restart purposes.
    `KafkaItemReaderBuilder<K,V>` | `topic(java.lang.String topic)` A topic name to manually assign to the consumer.

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

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

- - ### Constructor Detail

    - #### KafkaItemReaderBuilder

          public KafkaItemReaderBuilder()

  - ### Method Detail

    - #### saveState

          public KafkaItemReaderBuilder<K,V> saveState(boolean saveState)

      Configure if the state of the `ItemStreamSupport` should be persisted within the `ExecutionContext` for restart purposes.
      Parameters:
        `saveState` - defaults to true
      Returns:
        The current instance of the builder.

    - #### name

          public KafkaItemReaderBuilder<K,V> name(java.lang.String name)

      The name used to calculate the key within the `ExecutionContext`. Required if `saveState(boolean)` is set to true.
      Parameters:
        `name` - name of the reader instance
      Returns:
        The current instance of the builder.
      See Also:
        `ItemStreamSupport.setName(String)`

    - #### consumerProperties

          public KafkaItemReaderBuilder<K,V> consumerProperties(java.util.Properties consumerProperties)

      Configure the underlying consumer properties.

      `consumerProperties` must contain the following keys: 'bootstrap.servers', 'group.id', 'key.deserializer' and 'value.deserializer'

      .
      Parameters:
        `consumerProperties` - properties of the consumer
      Returns:
        The current instance of the builder.

    - #### partitions

          public KafkaItemReaderBuilder<K,V> partitions(java.lang.Integer... partitions)

      A list of partitions to manually assign to the consumer.
      Parameters:
        `partitions` - list of partitions to assign to the consumer
      Returns:
        The current instance of the builder.

    - #### partitions

          public KafkaItemReaderBuilder<K,V> partitions(java.util.List<java.lang.Integer> partitions)

      A list of partitions to manually assign to the consumer.
      Parameters:
        `partitions` - list of partitions to assign to the consumer
      Returns:
        The current instance of the builder.

    - #### topic

          public KafkaItemReaderBuilder<K,V> topic(java.lang.String topic)

      A topic name to manually assign to the consumer.
      Parameters:
        `topic` - name to assign to the consumer
      Returns:
        The current instance of the builder.

    - #### pollTimeout

          public KafkaItemReaderBuilder<K,V> pollTimeout(java.time.Duration pollTimeout)

      Set the pollTimeout for the poll() operations. Default to 30 seconds.
      Parameters:
        `pollTimeout` - timeout for the poll operation
      Returns:
        The current instance of the builder.
      See Also:
        `KafkaItemReader.setPollTimeout(Duration)`

    - #### build

          public KafkaItemReader<K,V> build()