Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Hands-On Reactive Programming in Spring 5
Hands-On Reactive Programming in Spring 5

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

eBook
€8.99 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Hands-On Reactive Programming in Spring 5

Reactive Programming in Spring - Basic Concepts

The previous chapter explained why it is important to build reactive systems and how reactive programming helps to do this. In this section, we will look at some toolsets that have already been present in Spring Framework for some time. We will also learn the important basic concepts of reactive programming by exploring the RxJava library, which is the first and most well-known reactive library in the Java world.

In this chapter, we will cover the following topics:

  • Observer pattern
  • Publish-Subscribe implementation provided by Spring
  • Server-sent events
  • RxJava history and base concepts
  • Marble diagrams
  • Business cases implemented by applying reactive programming
  • The current landscape of reactive libraries

Early reactive solutions in Spring

We have previously mentioned that there are a lot of patterns and programming techniques that are capable of becoming building blocks for the reactive system. For example, callbacks and CompletableFuture are commonly used to implement the message-driven architecture. We also mentioned reactive programming as a prominent candidate for such a role. Before we explore this in more detail, we need to look around and find other solutions that we have already been using for years.

In Chapter 1, Why Reactive Spring?, we saw that Spring 4.x introduced the ListenableFuture class, which extends the Java Future and makes it possible to leverage the asynchronous execution of operations such as HTTP requests. Unfortunately, only a handful of Spring 4.x components support the newer Java 8 CompletableFuture, which introduces some neat methods for asynchronous...

RxJava as a reactive framework

For some time, there was a standard library for reactive programming on Java platforms—namely RxJava 1.x (see https://github.com/ReactiveX/RxJava for more details). That library paved the way for reactive programming as we know it in the Java world today. At the moment, it is not the only library of this kind; we also have Akka Streams and Project Reactor. The latter is covered in detail in Chapter 4, Project Reactor - the Foundation for Reactive Apps. So, currently, we have a few options from which we may choose. Furthermore, RxJava itself has changed a lot with the release of version 2.x. However, to understand the most basic concepts of reactive programming and the reasoning behind them, we will be focusing on the most fundamental part of the RxJava only, on the API, which has...

Brief history of reactive libraries

Now that we are acquainted with RxJava and have even written a few reactive workflows, let's look at its history to recognize the context in which reactive programming was born and the problems it was designed to solve.

Curiously, the RxJava history and the history of reactive programming as we know it today began inside of Microsoft. In 2005, Erik Meijer and his Cloud Programmability Team were experimenting with programming models appropriate for building large-scale asynchronous and data-intensive internet service architectures. After some years of experimenting, the first version of the Rx library was born in the summer of 2007. An additional two years were devoted to different aspects of the library, including multithreading and cooperative re-scheduling. The first public version of Rx.NET was shipped on November 18, 2009. Later...

Reactive landscape

In the previous sections, we learned how to use pure RxJava and how to combine it with Spring Web MVC. To demonstrate the benefits of this, we have updated our temperature-monitoring application and improved the design by applying RxJava. However, it is worth noting that Spring Framework and RxJava is not the only valid combination. A lot of application servers also value the power of the reactive approach. As such authors of a successful reactive server called Ratpack decided to adopt RxJava as well.

Along with callbacks and a promise-based API, Ratpack provides RxRatpack, a separate module that allows to convert Ratpack Promise to RxJava Observable easily, and vice versa, as shown in the following code:

Promise<String> promise = get(() -> "hello world");
RxRatpack
.observe(promise)
.map(String::toUpperCase)
.subscribe...

Summary

In this chapter, we have revisited a few well-known design patterns by GoF—including Observer, Publish-Subscribe, and Iterator to build the basis of reactive programming. We have written a few implementations to review both the strong and weak sides of the instruments we already have for asynchronous programming. We have also leveraged Spring Framework support for Server-Sent Events, WebSockets, and also played with Event-Bus provided by Spring. Also, we have used Spring Boot and start.spring.io for fast application bootstrapping. Even though our examples were pretty simple, they demonstrated the potential issues that arise from immature approaches that are used for asynchronous data processing.

We also looked at reactive programming's history to highlight architectural problems, which reactive programming was invented to fight against. In this context...

Left arrow icon Right arrow icon
Download code icon Download Code

Key benefits

  • 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

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!

Who is this book 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.

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

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Oct 08, 2018
Length: 556 pages
Edition : 1st
Language : English
ISBN-13 : 9781787287297
Category :
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Oct 08, 2018
Length: 556 pages
Edition : 1st
Language : English
ISBN-13 : 9781787287297
Category :
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 102.97
Hands-On Spring Security 5 for Reactive Applications
€32.99
Hands-On Reactive Programming in Spring 5
€36.99
Hands-On Reactive Programming with Reactor
€32.99
Total 102.97 Stars icon
Banner background image

Table of Contents

11 Chapters
Why Reactive Spring? Chevron down icon Chevron up icon
Reactive Programming in Spring - Basic Concepts Chevron down icon Chevron up icon
Reactive Streams - the New Streams&#x27; Standard Chevron down icon Chevron up icon
Project Reactor - the Foundation for Reactive Apps Chevron down icon Chevron up icon
Going Reactive with Spring Boot 2 Chevron down icon Chevron up icon
WebFlux Async Non-Blocking Communication Chevron down icon Chevron up icon
Reactive Database Access Chevron down icon Chevron up icon
Scaling Up with Cloud Streams Chevron down icon Chevron up icon
Testing the Reactive Application Chevron down icon Chevron up icon
And, Finally, Release It! Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.6
(7 Ratings)
5 star 42.9%
4 star 14.3%
3 star 14.3%
2 star 14.3%
1 star 14.3%
Filter icon Filter
Top Reviews

Filter reviews by




fedir.sirko Sep 16, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
At the moment, I am working on the project where we apply reactive stack with Spring. At first, I had terrible times understanding why it matters. Now, I am positive about reactive programming as a concept & help newcomers with it.This book is slightly longer than I wish it were (over 500 pages!). Sometimes, it has strange phrases (authors are not native speakers). However, still, I like it. The book has a lengthy explanation of why reactive programming appeared. It tells various stories (sometimes, too many), so you understand not only the current state of affairs, but all the historical context. After a rather lengthy intro, authors dive into RxJava, Reactor, WebFlux, reactive DB connectivity, reactive messaging, etc. Examples present, explanations present, hell-lot of diagrams is the book. Some aspects are not interesting to me (at least at the moment), other is what I need right now. It even has a separate chapter regarding monitoring reactive applications.Read this book. You will have no regrets.
Amazon Verified review Amazon
karthi Jan 20, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Author explains every concept in detail with examples.
Amazon Verified review Amazon
Shohra A Sep 29, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I like the way author explained the concepts, problem statement - inefficient existing solution - reactive way to solve. Wish I would have found this earlier.
Amazon Verified review Amazon
Dimitri K Jul 18, 2020
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
This book is very detailed and describes all kinds of APIs. It is certainly very useful and practical. One important part is almost missing however - the asynchronous. This word is of course repeated many times, but deep explanation is missing. I must admit that is is also missing in most other sources too. Maybe its too complicated for average reader and writer, I don't know. But without asynchronous part, why would anybody even think of using all this complicated API? I can take the authors word that it just works if you use this or that method. Still, little disappointed, after having read 300 pages.
Amazon Verified review Amazon
RJ Jan 26, 2023
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
First off, the authors clearly know this area well and I must admit the code for the book is great.The exposition, however, is terse. Repetitive, otherwise. Oleh and Igor are great (look them up) but may be the book's editors need to work on actually editing this stuff, eh?The three stars is on Packt, for sub par production quality. Oleh and Igor get 5 stars.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.