Reactive programming in Java

Java is not a reactive language. However, this does not mean that we cannot create reactive programs in Java. There are libraries that support different reactive programming approaches. I should mention that the Akka framework and ReactiveX also exist for other languages as well. With Java 9, the JDK starts to support reactive programming, providing a few classes and interfaces for this purpose. We will focus on these features now.

The JDK contains the java.util.concurrent.Flow class, which contains related interfaces and some static methods to support flow controlled programs. The model that this class supports is based on Publisher, Subscriber, and Subscription.

As a very simple explanation, a Publisher accepts ...

Get Java Projects - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.