Reactive in Spring Data

As well as the changes in the web layer, another vital part of most applications is the data layer that interacts with the storage. For many years, a robust solution that has been simplifying everyday development is the Spring Data project, which provides convenient abstractions for data access via the repository pattern. Since its early days, Spring Data has mostly provided synchronous blocking access to underlying areas of storage. Fortunately, the fifth generation of the Spring Data framework offers new possibilities for reactive and nonblocking access to the database layer. In the new generation, Spring Data offers the ReactiveCrudRepository interface, which exposes Project Reactor's reactive types for seamless integration with reactive workflows. Consequently, it allows database connectors to be an efficient part of an utterly reactive application.

As well as the reactive repository, Spring Data provides a couple of modules that integrate with the storage methods by extending the ReactiveCrudRepository interface. The following is a list of storage methods that now have a reactive integration in Spring Data:

  • MongoDB via the Spring Data Mongo Reactive module: This is an entirely reactive and nonblocking interaction with the NoSQL database, and it is also a proper backpressure control.
  • Cassandra via the Spring Data Cassandra Reactive module: This is an asynchronous and nonblocking interaction with the Cassandra data storage that supports backpressure over the TCP flow control.
  • Redis via the Spring Data Redis Reactive module: This is a reactive integration with Redis over the Lettuce Java client. 
  • Couchbase via the Spring Data Couchbase Reactive module: This is a reactive Spring Data integration with the Couchbase database over the RxJava-based driver.

Moreover, all of these modules are supported by Spring Boot, which provides additional starter modules that offer smooth integration with their chosen storage method.

Furthermore, as well as NoSQL databases, Spring Data also introduces Spring Data JDBC, a lightweight integration with JDBC that may soon offer Reactive JDBC connectivity. Reactive data access is covered in Chapter 7, Reactive Database Access.

To summarize, the fifth generation of Spring Data completes the end-to-end reactive data stream from the web endpoints to the reactive database integration, which covers the needs of most applications. In turn, as we will see in the following sections, most of the improvement in the other Spring Framework modules are based either on the reactive capabilities of WebFlux or reactive Spring Data modules.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.99.152