Handling RxJava Observables in a Web UI

Before we dive into the meat of this article, let's start with some definitions.

RxJava: A Java VM implementation of Reactive Extensions: a library for composing asynchronous and event-based programs by using observable sequences. It is popular, as it addresses the concerns about low-level threading, synchronization, thread-safety and concurrent data structures.

Introduction to Reactive Programming

Reactive programming is about dealing with data streams and the propagation of change.

Reactive systems are applications whose architectural approach make them responsive, resilient, elastic and message-driven.

RxJava to Kotlin Coroutines: End-to-End Feature Migration

Kotlin coroutines are much more than just lightweight threads — they are a new paradigm that helps developers to deal with concurrency in a structured and idiomatic way.

When developing an Android app, one should consider many different things: taking long-running operations off the UI thread, handling lifecycle events, canceling subscriptions, switching back to the UI thread to update the user interface.

Reactive REST API Using Spring Boot and RxJava

I’m not going to explain what reactive programming is or why you should use it. I hope you’ve already read about it somewhere, and if not, you can Google it. In this post, I’m going to tell you how to use reactive programming specifically with Spring Boot and RxJava. Let's get started.

Prerequisites

Before you continue reading, I expect you understand how to create simple REST API using Spring Boot and RxJava. If you haven’t, you can learn more about Spring Boot on Baeldung and you can learn more about RxJava on AndroidHive. They explain those two materials really well.

A Bird’s-Eye View on Java Concurrency Frameworks

The Why Question

A few years ago when NoSQL was trending, like every other team, our team was also enthusiastic about the new and exciting stuff; we were planning to change the database in one of the applications. But when we got into the finer details of the implementation, we remembered what a wise man once said, “the devil is in the details,” and eventually, we realized that NoSQL is not a silver bullet to fixing all problems, and the answer to NoSQL VS RDMS was: “It depends.” Similarly, in the last year, concurrency libraries like RX-Java and Spring Reactor were trending with enthusiastic statements, like the asynchronous, non-blocking approach is the way to go, etc. In order to not make the same mistake again, we tried to evaluate how concurrency frameworks like ExecutorService, RxJava, Disruptor, and Akka differ from one another and how to identify the right use case for respective frameworks.

Terminologies used in this article are described in greater detail here.