Spring-Kafka vs. Spring-Cloud-Stream (Kafka)

Eike Behrends picture Eike Behrends · Nov 15, 2017 · Viewed 8.5k times · Source

Using Kafka as a messaging system in a microservice architecture what are the benefits of using spring-kafka vs. spring-cloud-stream + spring-cloud-starter-stream-kafka ?

The spring cloud stream framework supports more messaging systems and has therefore a more modular design. But what about the functionality ? Is there a gap between the functionality of spring-kafka and spring-cloud-stream + spring-cloud-starter-stream-kafka ? Which API is better designed?

Looking forward to read about your opinions

Answer

Warren Zhu picture Warren Zhu · Oct 10, 2018

Spring Cloud Stream with kafka binder rely on Spring-kafka. So the former has all functionalities supported by later, but the former will be more heavyweight. Below are some points help you make the choice:

  1. If you might change kafka into another message middle-ware in the future, then Spring Cloud stream should be your choice since it hides implementation details of kafka.
  2. If you want to integrate other message middle with kafka, then you should go for Spring Cloud stream, since its selling point is to make such integration easy.
  3. If you want to enjoy the simplicity and not accept performance overhead, then choose spring-kafka
  4. If you plan to migrate to public cloud service, then use spring cloud stream which is part of spring cloud family.