liveBook · Manning

Spring Boot

As explained in Kafka Streams in Action, Second Edition

Spring Boot is a Spring-based framework that simplifies application development through auto-configuration, convention-based defaults, and embedded application services.

Spring Boot extends Spring with convention-over-configuration defaults, reducing the infrastructure needed to build Kafka applications. It can also provide a built-in web server. section 12.2 section 12.3

A Spring Boot Kafka application typically combines:

  • @SpringBootApplication identifies the application and configuration class, while application.properties supplies values injected with @Value. section 12.2
  • NewTopic beans declare the Kafka topics required by the application, including partition and replication settings. section 12.2
  • @EnableKafka activates Spring Kafka support; @EnableKafkaStreams activates Spring Boot support for Kafka Streams applications. section 12.3 section 12.4
  • Kafka Streams applications can use the default lifecycle management or retain more control by wiring Spring dependency injection around an explicit KafkaStreams instance. section 12.3 section 12.4

Loan application processing

A loan website publishes applications to an input topic. An underwriting application processes them and sends accepted, rejected, and randomly selected quality-assurance results to separate topics. A Spring Boot configuration class can inject topic properties, declare NewTopic beans, and start without a web server when configured with WebApplicationType.NONE. The same application can later become a Kafka Streams topology that aggregates approvals and rejections, with the default web server supporting interactive-query endpoints. section 12.2 section 12.3

Listing 12.4 Basic configuration, which is substantially less with Spring Boot
@Configuration
public class LoanApplicationProcessingApplication {
    @Value("${application.group}")
    private String groupId;

    @Value("${loan.app.input.topic}")         #1
    private String loanAppInputTopic;

    // Other configurations left out for clarity

   @Bean
   public NewTopic loanAppInputTopic() {         #2
        return new NewTopic(loanAppInputTopic,
                            partitions,
                            replicationFactor);
   }

   // Other NewTopic beans left out for clarity

Inspect the reduced configuration pattern: injected topic properties and NewTopic beans replace much of the surrounding Kafka infrastructure code. section 12.2

How Kafka Streams in Action, Second Edition covers it

How deep it goes
Demonstrates configuration classes, property injection, topic beans, startup, and alternative Kafka Streams lifecycle wiring.
Examples
Uses a loan-processing workflow with input, approval, rejection, quality-assurance, and Kafka Streams aggregation topics.
What it assumes
Assumes Spring and Kafka familiarity while demonstrating the configuration needed to connect them.
What you can do after
Build Kafka applications with reduced configuration and choose between managed or explicitly controlled Kafka Streams lifecycles.
How it connects
Connects Spring, Spring Kafka, Kafka, Kafka Streams, dependency injection, interactive queries, and embedded web servers.

Also explained in

Compare how 4 books explain Spring Boot →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kafka Streams in Action, Second Edition. The section links point to the parts of the book it draws on.