chapter eight

8 Reactive Spring Boot application development

 

This chapter covers

  • Introducing reactive programming with Spring WebFlux
  • Developing reactive RESTful APIs with annotated controller and functional endpoints
  • Accessing reactive RESTful APIs with WebClient
  • Developing Spring Boot applications with RSocket
  • Using WebSocket and Spring Boot to develop applications

In the previous chapter, we explored how to design and develop RESTful API with Spring Boot. Spring Framework offers an alternative technology stack with Spring WebFlux to develop reactive applications. Spring WebFlux, which is based on Project Reactor, offers utilities that allow you to design reactive applications with controls, such as nonblocking, backpressure, and writing code in a declarative manner. It also provides the WebClient utility with a fluent API to consume the APIs.

In this chapter, we’ll look at RSocket and WebSocket protocols, which offer support for bidirectional communication between the communicating parties. Lastly, we’ll demonstrate how to use these protocols in a Spring Boot application. Let’s get started.

8.1 Introduction to reactive programming

Reactive programming is programming with asynchronous data streams. Let’s cover the asynchronous data stream with a discussion of the terms asynchronous and data streams.

8.1.1 Backpressure

8.1.2 Benefits of reactive programming

8.2 Understanding Project Reactor

8.3 Introducing Spring WebFlux

8.3.1 Technique: Developing a reactive RESTful API with annotated controllers

8.3.2 Technique: Developing a reactive RESTful API with functional endpoints

8.4 Testing reactive applications

8.4.1 Technique: Using WebClient to build an API client

8.5 Introduction to RSocket

8.5.1 Technique: Developing applications using RSocket and Spring Boot

8.6 Introduction to WebSocket