Class KafkaItemReaderBuilder<K,V>
java.lang.Object
org.springframework.batch.item.kafka.builder.KafkaItemReaderBuilder<K,V>
A builder implementation for the
KafkaItemReader
.- Since:
- 4.2
- Author:
- Mathieu Ouellet, Mahmoud Ben Hassine
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
consumerProperties
(Properties consumerProperties) Configure the underlying consumer properties.The name used to calculate the key within theExecutionContext
.partitionOffsets
(Map<org.apache.kafka.common.TopicPartition, Long> partitionOffsets) Setter for partition offsets.partitions
(Integer... partitions) A list of partitions to manually assign to the consumer.partitions
(List<Integer> partitions) A list of partitions to manually assign to the consumer.pollTimeout
(Duration pollTimeout) Set the pollTimeout for the poll() operations.saveState
(boolean saveState) Configure if the state of theItemStreamSupport
should be persisted within theExecutionContext
for restart purposes.A topic name to manually assign to the consumer.
-
Constructor Details
-
KafkaItemReaderBuilder
public KafkaItemReaderBuilder()
-
-
Method Details
-
saveState
Configure if the state of theItemStreamSupport
should be persisted within theExecutionContext
for restart purposes.- Parameters:
saveState
- defaults to true- Returns:
- The current instance of the builder.
-
name
The name used to calculate the key within theExecutionContext
. Required ifsaveState(boolean)
is set to true.- Parameters:
name
- name of the reader instance- Returns:
- The current instance of the builder.
- See Also:
-
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
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
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.
-
partitionOffsets
public KafkaItemReaderBuilder<K,V> partitionOffsets(Map<org.apache.kafka.common.TopicPartition, Long> partitionOffsets) Setter for partition offsets. This mapping tells the reader the offset to start reading from in each partition. This is optional, defaults to starting from offset 0 in each partition. Passing an empty map makes the reader start from the offset stored in Kafka for the consumer group ID.In case of a restart, offsets stored in the execution context will take precedence.
- Parameters:
partitionOffsets
- mapping of starting offset in each partition- Returns:
- The current instance of the builder.
-
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
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:
-
build
-