10 Event-driven architecture with Spring Cloud Stream

 

This chapter covers

  • Understanding event-driven architecture processing and its relevance
  • Using Spring Cloud Stream to simplify event processing
  • Configuring Spring Cloud Stream
  • Publishing messages with Spring Cloud Stream and Kafka
  • Consuming messages with Spring Cloud Stream and Kafka
  • Implementing distributed caching with Spring Cloud Stream, Kafka, and Redis

Human beings are always in a state of motion as they interact with their environment. Typically, their conversations aren’t synchronous, linear, or as narrowly defined as a request-response model. It’s something more like message-driven, where we’re constantly sending and receiving messages from the things around us. As we receive messages, we react to those messages, often interrupting the primary task that we’re working on.

10.1 The case for messaging, EDA, and microservices

10.1.1 Using a synchronous request-response approach to communicate state change

10.1.2 Using messaging to communicate state changes between services

10.1.3 Downsides of a messaging architecture

10.2 Introducing Spring Cloud Stream

10.3 Writing a simple message producer and consumer

10.3.1 Configuring Apache Kafka and Redis in Docker

10.3.2 Writing the message producer in the organization service

10.3.3 Writing the message consumer in the licensing service

10.3.4 Seeing the message service in action

10.4 A Spring Cloud Stream use case: Distributed caching

10.4.1 Using Redis to cache lookups

10.4.2 Defining custom channels

Summary