Add Kafka ItemWriter

This commit adds an ItemWriter implementation for Apache Kafka using
a KafkaTemplate with default topic set. Extending KeyValueItemWriter,
the writer requires a Converter to map the Kafka ProducerRecord's key
from the item.

Resolves BATCH-2765
This commit is contained in:
Mathieu Ouellet
2018-10-26 07:48:28 -04:00
committed by Mahmoud Ben Hassine
parent 96ec0d0d27
commit 06556dc97e
9 changed files with 379 additions and 0 deletions

View File

@@ -102,6 +102,9 @@
and handles some transaction-related work that a non-"JPA-aware"
`ItemWriter` would not need to know about and
then delegates to another writer to do the actual writing.
|KafkaItemWriter|Using a `KafkaTemplate` object, items are written to the default topic through the
`KafkaTemplate#sendDefault(Object, Object)` method using a `Converter` to map the key from the item.
A delete flag can also be configured to send delete events to the topic.
|MimeMessageItemWriter|Using Spring's `JavaMailSender`, items of type `MimeMessage`
are sent as mail messages.
|MongoItemWriter|Given a `MongoOperations` object, items are written

View File

@@ -3054,6 +3054,7 @@ Spring Batch offers the following readers and writers for commonly used messagin
* <<amqpItemWriter>>
* <<jmsItemReader>>
* <<jmsItemWriter>>
* <<kafkaItemWriter>>
[[amqpItemReader]]
===== `AmqpItemReader`
@@ -3081,6 +3082,12 @@ The `JmsItemWriter` is an `ItemWriter` for JMS that uses a `JmsTemplate`. The te
should have a default destination, which is used to send items in `write(List)`. Spring
Batch provides a `JmsItemWriterBuilder` to construct an instance of the `JmsItemWriter`.
[[kafkaItemWriter]]
===== `KafkaItemWriter`
The `KafkaItemWriter` is an `ItemWriter` for Apache Kafka that uses a `KafkaTemplate` to
send events to a default topic. Spring Batch provides a `KafkaItemWriterBuilder` to
construct an instance of the `KafkaItemWriter`.
[[databaseReaders]]
==== Database Readers
Spring Batch offers the following database readers: