Class KafkaItemWriterBuilder<K,V>
java.lang.Object
org.springframework.batch.item.kafka.builder.KafkaItemWriterBuilder<K,V>
A builder implementation for the
KafkaItemWriter
- Since:
- 4.2
- Author:
- Mathieu Ouellet, Mahmoud Ben Hassine
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Validates and builds aKafkaItemWriter
.delete
(boolean delete) Indicate if the items being passed to the writer are all to be sent as delete events to the topic.itemKeyMapper
(org.springframework.core.convert.converter.Converter<V, K> itemKeyMapper) Set theConverter
to use to derive the key from the item.kafkaTemplate
(org.springframework.kafka.core.KafkaTemplate<K, V> kafkaTemplate) Establish the KafkaTemplate to be used by the KafkaItemWriter.timeout
(long timeout) The time limit to wait when flushing items to Kafka.
-
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 theConverter
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
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
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
Validates and builds aKafkaItemWriter
.- Returns:
- a
KafkaItemWriter
-