Mastering Reactive Streams: How Non‑Blocking Backpressure Works

This article explains the Reactive Streams standard, its back‑pressure concept—including blocking and non‑blocking approaches—and details the core API types (Publisher, Subscriber, Subscription) and their interaction flow for asynchronous data processing.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
Mastering Reactive Streams: How Non‑Blocking Backpressure Works

Reactive Streams

Reactive Streams is an asynchronous stream‑processing standard that uses a non‑blocking back‑pressure mechanism.

Back pressure is the key concept. In an asynchronous model, a consumer subscribes to a producer and provides callbacks; when the producer emits data faster than the consumer can handle it, the consumer must signal the producer to slow down. This signaling mechanism is called back pressure.

Back pressure can be blocking or non‑blocking .

Blocking is simple: producer and consumer run on the same thread, so when the consumer processes, the producer does not send new data.

Non‑blocking switches from a push model to a pull model. In the push model the producer decides when to send data; in the pull model the consumer requests a specific amount of data, and the producer sends that amount before waiting for the next request.

Important API Types

Publisher

Produces data for subscribers; it has a single method subscribe(Subscriber).

Subscriber

Subscribes to a publisher and receives data via onNext(T), error via onError(Throwable), and completion via onComplete(). Before these, the publisher calls onSubscription(Subscription).

Subscription

Represents the connection between publisher and subscriber; the subscriber uses it to request more data with request(long) or to cancel the connection with cancel().

Overall Flow

Create a Publisher and a Subscriber .

Link them via Publisher::subscribe.

The publisher creates a Subscription and calls Subscriber::onSubscription, establishing the connection.

The subscriber calls Subscription::request to request a certain number of items.

The publisher calls Subscriber::onNext to deliver data, not exceeding the requested amount.

When the publisher has no more data it calls Subscriber::onComplete; on error it calls Subscriber::onError.

The subscriber can request more data or close the connection with Subscription::cancel.

This shows that the subscriber actively requests data via Subscription::request, implementing non‑blocking back pressure.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaAsynchronoussubscriptionReactive StreamsbackpressurePublisherSubscriber
Java High-Performance Architecture
Written by

Java High-Performance Architecture

Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.