Kafka with Spring Batch

Sajith vijesekara
2 min readApr 17, 2020

Last couple of days I was working project which required to read kafka Stream & pass to Spring Batch jobs.

For Above Scenario We have to Use spring batch 4.2. It supports KafkaItemReader which can directly pass to spring batch as ItemReader.


  1. Kafka 2.5.0

2. Spring boot 2.2.6

For Above Solution first need to setup apache kafka with 1 zookeepr instance. Then Create Spring boot Application which need to add these dependencies.

Adding Required Configurations.

Based on spring kafka integration & spring jpa configuration we have to add following configurations.

Step 2. Create Object Class which need to be passed in kafka stream.

Step 3. Create Repositroy Class which need to save data to mysql

Step 4. Write Item Processor & Item Writer classes which need to run spring batch job.

Spring Batch Configuration

We have to add below configuration class which have the all bean configuration for spring batch setup.

And This way We can Start jobs. Then You can see that all the customer data will be saved in mysql database.

If you need any help please put message here or you can contact me here



Sajith vijesekara

Technical Lead. Passionate about cloud computing & web security | Freelance Mobile Developer| CKAD | AWS Community Builder 🇱🇰