Classic Integration: Topology and State Store

Learn how to create a Kafka Streams topology and query a state store with a REST API using Spring Boot.

Topology creation

With the dependencies, configuration, and topics set up, we can create our topology. We will create a new class and annotate it with @Component. This annotation marks the class for Spring Boot to be managed as a bean, meaning Spring Boot is in charge of the life cycle of this class. Spring boot will instantiate this class and inject the required dependencies it has.

The topology itself will be created inside a method accepting a StreamsBuilder instance. The method should be annotated with @Autowired, indicating that its arguments are automatically injected by Spring Boot. With the StreamsBuilder, creating the topology is no different than creating it in a non-Spring Boot application:

Get hands-on with 1200+ tech skills courses.