𝔖 Scriptorium
✦   LIBER   ✦

📁

Hands-On Reactive Programming in Spring 5: Build cloud-ready, reactive systems with Spring 5 and Project Reactor

✍ Scribed by Dokuka, Oleh, Lozynskyi, Igor


Publisher
Packt Publishing
Year
2018
Tongue
English
Leaves
545
Category
Library

⬇  Acquire This Volume

No coin nor oath required. For personal study only.

✦ Synopsis


Explore the reactive system and create efficient microservices with Spring Boot 2.1 and Spring Cloud

Key Features

  • Understand the kind of system modern businesses require with Spring
  • Gain deeper insights into reactive programming with Reactor and Spring Cloud
  • Get in-depth knowledge on asynchronous and nonblocking communication with Spring 5 WebFlux

Book Description

These days, businesses need a new type of system that can remain responsive at all times. This is achievable with reactive programming; however, the development of these kinds of systems is a complex task, requiring a deep understanding of the domain. In order to develop highly responsive systems, the developers of the Spring Framework came up with Project Reactor.

Hands-On Reactive Programming in Spring 5 begins with the fundamentals of Spring Reactive programming. You'll explore the endless possibilities of building efficient reactive systems with the Spring 5 Framework along with other tools such as WebFlux and Spring Boot. Further on, you'll study reactive programming techniques and apply them to databases and cross-server communication. You will advance your skills in scaling up Spring Cloud Streams and run independent, high-performant reactive microservices.

By the end of the book, you will be able to put your skills to use and get on board with the reactive revolution in Spring 5.1!

What you will learn

  • Discover the difference between a reactive system and reactive programming
  • Explore the benefits of a reactive system and understand its applications
  • Get to grips with using reactive programming in Spring 5
  • Gain an understanding of Project Reactor
  • Build a reactive system using Spring 5 and Project Reactor
  • Create a highly efficient reactive microservice with Spring Cloud
  • Test, monitor, and release reactive applications

Who this book is for

This book is for Java developers who use Spring to develop their applications and want to build robust and reactive applications that can scale in the cloud. Basic knowledge of distributed systems and asynchronous programming will help you understand the concepts covered in this book.

Table of Contents

  1. Why Reactive Spring
  2. Reactive Programming in Spring - Basic Concepts
  3. Reactive Streams - the new Streams' Standard
  4. Project Reactor - the Foundation for Reactive Apps
  5. Going Reactive with Spring Boot 2
  6. Async nonblocking communication with Spring 5 WebFlux
  7. Reactive Database access
  8. Scale up with Spring Cloud Streams and Reactive Microservices
  9. Testing the Reactive Application
  10. And, Finally Release It

✦ Table of Contents


Cover
Title Page
Copyright and Credits
Dedication
Packt Upsell
Foreword
Contributors
Table of Contents
Preface
Chapter 1: Why Reactive Spring?
Why reactive?
Message-driven communication
Reactivity use cases
Why Reactive Spring? 
Reactivity on the service level
Summary
Chapter 2: Reactive Programming in Spring - Basic Concepts
Early reactive solutions in Spring
Observer pattern
Observer pattern usage example
Publish-Subscribe pattern with @EventListener
Building applications with @EventListener
Bootstrapping a Spring application
Implementing business logic
Asynchronous HTTP with Spring Web MVC
Exposing the SSE endpoint
Configuring asynchronous support  
Building a UI with SSE support
Verifying application functionality
Criticism of the solution
RxJava as a reactive framework
Observer plus iterator equals Reactive Stream
Producing and consuming streams
Generating an asynchronous sequence
Stream transformation and marble diagrams
Map operator
Filter operator
Count operator
Zip operator
Prerequisites and benefits of RxJava
Rebuilding our application with RxJava
Implementing business logic
Custom SseEmitter
Exposing the SSE endpoint
Application configuration
Brief history of reactive libraries
Reactive landscape
Summary
Chapter 3: Reactive Streams - the New Streams' Standard
Reactivity for everyone
The API's inconsistency problem
Pull versus push
The flow control problem
Slow producer and fast consumer
Fast producer and slow consumer
Unbounded queue
Bounded drop queue
Bounded blocking queue
The solution
The basics of the Reactive Streams spec
Reactive Streams spec in action
The introduction of the Processor notion 
Reactive Streams technology compatibility kit
The Publisher verification
The Subscriber verification
JDK 9
Advanced - async and parallel in Reactive Streams
Transfiguration of the Reactive Landscape
RxJava transfiguration
Vert.x adjustments
Ratpack improvements
MongoDB Reactive Streams driver 
A composition of reactive technologies in action
Summary
Chapter 4: Project Reactor - the Foundation for Reactive Apps
A brief history of Project Reactor
Project Reactor version 1.x
Project Reactor version 2.x
Project Reactor essentials
Adding Reactor to the project
Reactive types – Flux and Mono
Flux
Mono
Reactive types of RxJava 2
Observable
Flowable
Single
Maybe
Completable
Creating Flux and Mono sequences
Subscribing to Reactive Streams
Implementing custom subscribers
Transforming reactive sequences with operators
Mapping elements of reactive sequences 
Filtering reactive sequences
Collecting reactive sequences
Reducing stream elements
Combining Reactive Streams
Batching stream elements
The flatMap, concatMap, and flatMapSequential operators
Sampling elements 
Transforming reactive sequences into blocking structures
Peeking elements while sequence processing
Materializing and dematerializing signals
Finding an appropriate operator
Creating streams programmatically
Factory methods – push and create
Factory method – generate
Wrapping disposable resources into Reactive Streams
Wrapping reactive transactions with the usingWhen factory
Handling errors
Backpressure handling
Hot and cold streams
Multicasting elements of a stream
Caching elements of a stream
Sharing elements of a stream
Dealing with time
Composing and transforming Reactive Streams
Processors
Testing and debugging Project Reactor
Reactor Addons
Advanced Project Reactor 
Reactive Streams life cycle
Assembly-time
Subscription-time
Runtime
The thread scheduling model in Reactor
The publishOn operator
Parallelization with the publishOn operator
The subscribeOn operator
The parallel operator
Scheduler
Rector Context
Internals of Project Reactor
Macro-fusion
Micro-fusion
Summary
Chapter 5: Going Reactive with Spring Boot 2
A fast start as the key to success
Using Spring Roo to try to develop applications faster
Spring Boot as a key to fast-growing applications
Reactive in Spring Boot 2.0
Reactive in Spring Core
Support for reactive types conversion
Reactive I/O
Reactive in web
Reactive in Spring Data
Reactive in Spring Session
Reactive in Spring Security
Reactive in Spring Cloud
Reactive in Spring Test
Reactive in monitoring
Summary
Chapter 6: WebFlux Async Non-Blocking Communication
WebFlux as a central reactive server foundation
The reactive web core
The reactive web and MVC frameworks
Purely functional web with WebFlux
Non-blocking cross-service communication with WebClient
Reactive WebSocket API
Server-side WebSocket API 
Client-side WebSocket API
WebFlux WebSocket versus the Spring WebSocket module 
Reactive SSE as a lightweight replacement for WebSockets
Reactive template engines
Reactive web security
Reactive access to SecurityContext
Enabling reactive security
Interaction with other reactive libraries
WebFlux versus Web MVC
Laws matter when comparing frameworks 
Little's Law
Amdahl's Law
The Universal Scalability Law
Thorough analysis and comparison
Understanding the processing models in WebFlux and Web MVC
Impact of processing models on throughput and latency
Challenges with the WebFlux processing model
Impact of different processing models on memory consumption
Impact of processing models on usability
Application of WebFlux
Microservice-based systems
Systems that handle clients with slow connections
Streaming or real-time systems
WebFlux in action
Summary
Chapter 7: Reactive Database Access
Data handling patterns in the modern world
Domain-driven design
Data stores in the era of microservices
Polyglot persistence
Database as a Service
Sharing data across microservices
Distributed transactions
Event-driven architecture
Eventual consistency
The SAGA pattern
Event sourcing
Command Query Responsibility Segregation
Conflict-free replicated data types
Messaging system as a data store
Synchronous model for data retrieval
Wire protocol for database access
Database driver
JDBC
Connection management
Making relational database access reactive
Spring JDBC
Spring Data JDBC
Making Spring Data JDBC reactive
JPA
Making JPA reactive
Spring Data JPA
Making Spring Data JPA reactive
Spring Data NoSQL
Limitations of the synchronous model
Advantages of the synchronous model
Reactive data access with Spring Data
Using MongoDB reactive repository
Combining repository operations
How reactive repositories work
Pagination support
ReactiveMongoRepository implementation details
Using ReactiveMongoTemplate
Using reactive drivers (MongoDB)
Using asynchronous drivers (Cassandra)
Reactive transactions
Reactive transactions with MongoDB 4
Distributed transactions with the SAGA pattern
Spring Data reactive connectors
Reactive MongoDB connector
Reactive Cassandra connector
Reactive Couchbase connector
Reactive Redis connector
Limitations and anticipated improvements
Asynchronous Database Access
Reactive Relational Database Connectivity
Using R2DBC with Spring Data R2DBC
Transforming a synchronous repository into reactive
Using the rxjava2-jdbc library
Wrapping a synchronous CrudRepository
Reactive Spring Data in action
Summary
Chapter 8: Scaling Up with Cloud Streams
Message brokers as the key to message-driven systems
Server-side load balancing
Client-side load balancing with Spring Cloud and Ribbon
Message brokers as an elastic, reliable layer for message transferring
The market of message brokers
Spring Cloud Streams as a bridge to Spring Ecosystem
Reactive programming in the cloud
Spring Cloud Data Flow
The finest-grained application with Spring Cloud Function
Spring Cloud – function as a part of a data flow
RSocket for low-latency, reactive message passing
RSocket versus Reactor-Netty
RSocket in Java
RSocket versus gRPC
RSocket in Spring Framework
RSocket in other frameworks 
The ScaleCube Project
The Proteus Project
Summarizing RSocket
Summary
Chapter 9: Testing the Reactive Application
Why are reactive streams hard to test?
Testing reactive streams with StepVerifier
Essentials of StepVerifier
Advanced testing with StepVerifier
Dealing with virtual time
Verifying reactive context
Testing WebFlux
Testing Controllers with WebTestClient 
Testing WebSocket
Summary
Chapter 10: And, Finally, Release It!
The importance of DevOps-friendly apps
Monitoring the Reactive Spring application
Spring Boot Actuator
Adding an actuator to the project
Service info endpoint
Health information endpoint
Metrics endpoint
Loggers management endpoint
Other valuable endpoints
Writing custom actuator endpoints
Securing actuator endpoints
Micrometer
Default Spring Boot metrics
Monitoring Reactive Streams
Monitoring reactor flows
Monitoring reactor schedulers
Adding custom Micrometer meters
Distributed tracing with Spring Boot Sleuth
Pretty UI with Spring Boot Admin 2.x
Deploying to the cloud
Deploying to Amazon Web Services
Deploying to the Google Kubernetes Engine
Deploying to Pivotal Cloud Foundry
Discovering RabbitMQ in PCF
Discovering MongoDB in PCF
Configurationless deployment with Spring Cloud Data Flow for PCF
Knative for FaaS over Kubernetes and Istio
Bits of advice for successful application deployment
Summary
Other Books You May Enjoy
Index


📜 SIMILAR VOLUMES


Hands-On Reactive Programming with React
✍ Rahul Sharma 📂 Library 📅 2018 🏛 Packt Publishing 🌐 English

<p><b>Discover how project Reactor enhances the reactive programming paradigm and allows you to build scalable asynchronous applications</b></p> Key Features <li>Use reactive APIs, Flux, and Mono to implement reactive extensions </li> <li>Create concurrent applications without the complexity of Java

Hands-On Microservices with Kotlin: Buil
✍ Medina Iglesias, Juan Antonio 📂 Library 📅 2018 🏛 Packt Publishing 🌐 English

Kotlin has been the buzzword among developers ever since the release of new features in Kotlin 1.1. With Google's announcement of introducing first class support for Kotlin in their Android ecosystem, it's high time that Kotlin is realized as a mainstream language. Microservices aids in designing sc

Reactive Programming in Kotlin: Design a
✍ Rivu Chakraborty 📂 Library 📅 2017 🏛 Packt Publishing - ebooks Account 🌐 English

<p><b>Learn how to implement Reactive Programming paradigms with Kotlin, and apply them to web programming with Spring Framework 5.0 and in Android Application Development.</b></p><h4>Key Features</h4><ul><li>Learn how to solve blocking user experience with Reactive Programming and get deep insights

Reactive Programming in Kotlin: Design a
✍ Rivu Chakraborty 📂 Library 📅 2017 🏛 Packt Publishing - ebooks Account 🌐 English

<p><b>Learn how to implement Reactive Programming paradigms with Kotlin, and apply them to web programming with Spring Framework 5.0 and in Android Application Development.</b></p><h4>Key Features</h4><ul><li>Learn how to solve blocking user experience with Reactive Programming and get deep insights

Building Applications with Spring 5 and
✍ Milos Vasic 📂 Library 📅 2018 🏛 Packt Publishing 🌐 English

<p><span>Learn to build a full-fledged application in Spring and Kotlin taking a reactive, microservice-based approach for scalability and robustness in the cloud</span></p><h4><span>Key Features</span></h4><ul><li><span><span>Build a full-fledged application in Spring and Kotlin</span></span></li><

Hands-On Microservices with Django: Buil
✍ Tieme Woldman 📂 Library 📅 2024 🏛 Packt Publishing 🌐 English

Unlock the potential of microservices architecture and master the art of building scalable and resilient web applications using Django Key Features Deliver, optimize, and secure high-performing microservices in Django Apply community-standard components for microservices like DRF (RESTful APIs)