chapter ten

10 Event-driven architecture with Spring Cloud Stream

 

This chapter covers

  • Understanding event-driven architecture processing and its relevance to microservices
  • Using Spring Cloud Stream to simplify event processing in your microservices
  • 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, interacting with their environment while sending out and receiving information from the things around them. Typically, these conversations aren’t synchronous, linear, or narrowly defined to a request-response model. It’s something more like a message-driven, where we’re constantly sending and receiving messages. As we receive messages, we react to those messages, while often interrupting the primary task that we’re working on.

10.1   The case for messaging, EDA, and microservices

10.1.1   Using 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   Writing the message producer in the organization service

10.3.2   Writing the message consumer in the licensing service

10.3.3   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

10.5   Summary