Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Spring Kafka lib and native Kafka Java API

For a Java/Kotlin Spring boot app, if I want to send messages to Kafka or consume messages from Kafka. Would you recommend using Spring Kafka library or just using Kafka Java API.

Not quite sure are there any more benefits Spring provides or just a wrapper? For Spring they provide a lot of annotations which seems more magics when having some runtime error.

Want to hear some opinions.

like image 464
ttt Avatar asked Oct 31 '25 00:10

ttt


1 Answers

Full disclosure: I am the project lead for Spring for Apache Kafka.

It's entirely up to you and your colleagues.

It's somewhat comparable to writing assembly code Vs. using a high level language and a compiler.

For an existing Spring shop that is familiar with spring-messaging (JMS, RabbitMQ etc), it's a natural fit, the APIs will be very familiar (POJO listeners, MessageConverters, KafkaTemplate, etc, etc).

When using the simplest APIs, Spring takes care of the low-level stuff like committing offsets, transaction synchronization, error handling, etc, etc.

If you have very basic requirements and/or want to write all that code yourself, then use the native APIs.

like image 110
Gary Russell Avatar answered Nov 03 '25 00:11

Gary Russell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!