Spring Cloud Stream: Setup and Configuration

Learn how to build Kafka Streams applications using Spring Cloud Stream.

Spring Boot provides us with another programming model for writing event-driven applications in general, which also supports the Kafka Streams application called Spring Cloud Stream. Spring Cloud Stream allows us to build event-driven applications and microservices using the same concepts and models regardless of the actual technology being used. For specific technologies, such as RabbitMQ, SQS, or, in our case, Kafka Streams, Spring provides us with binders. Therefore, we’ll build a Kafka Streams application using Spring Cloud Stream and Spring Kafka Streams binder.

It is important to note that everything we can do with the classic, non-cloud-stream Kafka Streams integration, we can do with the cloud stream integration presented in this lesson. The difference is mainly in the programming style and approach, and choosing one over the other comes down to personal preferences.

Dependencies

The most convenient way to find out which maven dependencies are required is by using spring initializr. We are building a Kafka Streams application using Spring Cloud Stream, and we want to expose a state store using a REST API, so we need the following dependencies:

  • Cloud Stream

  • Spring for Apache Kafka Streams

  • Spring Web

Using the EXPLORE functionality, this is the build.gradle file that we need:

Get hands-on with 1200+ tech skills courses.