Introduction to Reactive Streams
Reactive Streams is an initiative to provide a standard for
asynchronous stream processing with non-blocking back
pressure. This encompasses efforts aimed at runtime environments
At their core, Reactive Streams are an effort to provide highly responsive applications able to handle many requests per second with the ability to manage backpressure (the ability to skip or queue data that is coming too fast to be processed). Asynchronous means processing can take place in many threads, without stopping to read data from a file or a web request for example. Although many implementations already exist for asynchronous processing, such as Java’s Future, Completable Future, and parallel streams, most of them do not have standard support for asynchronous handling of backpressure.
Reactive Streams are a unifying standard that abstracts existing
methods of concurrency. Also, by having one standard, different Reactive Streams implementations can interoperate in one application.
Java 9 was an important release of Java and includes Project Jigsaw which represents a huge restructuring of the core JDK (Java Development Kit) as well as a new and improved way of defining code dependencies. This provides compile-time errors when dependencies are missing as opposed to runtime errors, which is a vast improvement for software development efficiency. Java 9 also introduced a unified interface for Reactive Streams. Java 9 includes the following key features:
• Language updates
• Support for Reactive Streams
• Modularity (Project Jigsaw)
• Java REPL (jshell)
For the purposes of this article, we will focus on the second item and cover what Reactive Streams are and how they should be used. Although at the time of writing this is not the case, all implementations of Reactive Streams in Java are expected to implement the Java 9 API in the near future. We will cover changes in Java 10 and 11 in how they affect our code going forward.
Support for Reactive Streams has been added to the JDK. Several interfaces have been added in the java.util.concurrent.Flow class:
• Publisher<T>: A producer of items (and related control messages) received by Subscribers
• Subscriber<T>: A receiver of messages Chapter 1 Introduction to Reactive Streams
• Processor<T,R>: A component that acts as both a Subscriber and Publisher
• Subscription: Message control linking a Publisher and Subscriber
No actual implementation is included in the JDK; however, several
implementations already exist. Current notable implementations of
the Reactive Streams specification on the Java virtual machine (JVM) are Project Reactor (which is integrated in Spring 5), Akka Streams, and RxJava
if you want to learn java, you can contact with email@example.com