Reactive Streams
Reactive Streams started as an initiative in late 2013 between engineers at Netflix, Pivotal and Lightbend.
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 (JVM and JavaScript) as well as network protocols.
You can read the origin specification on official website of Reactive Streams.
Also, you can read the Chinese translation from here.
Asynchronous stream processing with non-blocking back pressure.
The Reactive Streams is composed of following:
- Asynchronous;
- Stream;
- Non-blocking;
- Back pressure.
The Java interfaces, you can find details on GitHub.
public interface Publisher<T> {
public void subscribe(Subscriber<? super T> s);
}
public interface Subscriber<T> {
public void onSubscribe(Subscription s);
public void onNext(T t);
public void onError(Throwable t);
public void onComplete();
}
public interface Subscription {
public void request(long n);
public void cancel();
}
public interface Processor<T, R> extends Subscriber<T>, Publisher<R> {
}
Reactive Extensions
An API for asynchronous programming with observable streams
ReactiveX is a combination of the best ideas from the Observer pattern, the Iterator pattern, and functional programming
Project Reactor
Reactor is a fourth-generation Reactive library for building non-blocking applications on the JVM based on the Reactive Streams Specification
- Composability and readability
- Data as a flow manipulated with a rich vocabulary of operators
- Nothing happens until you subscribe
- Backpressure or the ability for the consumer to signal the producer that the rate of emission is too high
- High level but high value abstraction that is concurrency-agnostic
Features:
- Fully non-blocking.
- Integrates Java API.
- Completable Future
- Stream
- Duration
- Flux and Mono.
- Implements the Reactive Streams specification.
You can find details on GitHub.
By the way, you can follow the Lite Rx API Hands-on to learn the basic APIs.
And here How to Choose Operators.
Reactor Netty
Reactor Netty
offers non-blocking and backpressure-readyTCP
/HTTP
/UDP
clients & servers based onNetty
framework.
Spring Framework WebFlux
The reactive-stack web framework, Spring WebFlux, was added later in version 5.0. It is fully non-blocking, supports Reactive Streams back pressure, and runs on such servers as Netty, Undertow, and Servlet 3.1+ containers
debug
.checkpoint
Hooks.onOperatorDebug()
- reactor-tools
ReactorDebugAgent
(works in production) java agent
RSocket
A binary protocol based on Reactive Streams back pressure
Features
- bi-directional
- multiplexed
- message-based
- binary protocol
Interaction Models
- request-response (1 to 1)
- fire and forget (1 to 0 udp)
- request stream (1 to many pub / sub)
- request channel (many to many)
Protocol
- WebSocket
- TCP
- UDP
Summary
Reactive Streams is a specification.
Project Reactor is JVM implementation base on the specification.
Spring WebFlux is Spring framework integration with Project Reactor.
RSocket is binary protocol base on the specification.