ttt
ttt

Reputation: 4004

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.

Upvotes: 4

Views: 2304

Answers (1)

Gary Russell
Gary Russell

Reputation: 174494

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.

Upvotes: 7

Related Questions