8 Reactive programming

 

This chapter covers

  • Learning what reactive programming is
  • Identifying why we want to write reactive code
  • Explaining SmallRye Mutiny as the reactive library used in Quarkus
  • Analyzing how the reactive paradigm integrates into the Quarkus architecture

We have touched on reactive programming throughout the book since we cannot always avoid it (especially if we want to use Hibernate Reactive). In this chapter, we finally dive into the reactive concepts to understand why you might consider using reactive programming in your applications.

The reactive programming paradigm is an alternative way of writing software programs. In contrast to the imperative model, which executes the program as a sequence of ordered steps, reactive programming focuses on asynchronous executions that notify the caller about the result only when the result computes or an error occurs. In this way, the caller thread is free to do any other work in the meantime and return to the request processing only when there is progress. This means that reactive systems can be more responsive and scalable as the same resources (both software and hardware) can do more work in the same time frame.

8.1 Being reactive

8.1.1 Handling of I/O operations

8.1.2 Writing reactive code

8.2 Mutiny

8.2.1 Reactive streams

8.2.2 Mutiny API

8.3 Reactive engine

8.4 Making Car Rental reactive

8.4.1 Reservation service

8.4.2 Inventory service

8.5 Virtual threads with project Loom

8.5.1 Project Loom in Quarkus

8.5.2 Problems with project Loom

8.6 Next steps

Summary