ArticleslgStudy

computer science

Reactive Streams

Reactive Streams is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Reactive Streams rather than just read about it. In short: Reactive Streams is an initiative to provide a standard for asynchronous stream processing with non-blocking back pressure. Origin Reactive Streams started as an initiative in late 2013 between engineers at Netflix, Pivotal and Lightbend.

Key takeaways

  • Reactive Streams belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Reactive Streams to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Reactive Streams from memory before moving on to harder problems.

Reference excerpt

Reactive Streams is an initiative to provide a standard for asynchronous stream processing with non-blocking back pressure.

Origin Reactive Streams started as an initiative in late 2013 between engineers at Netflix, Pivotal and Lightbend. Some of the earliest discussions began in 2013 between the Play and Akka teams at Lightbend. Lightbend is one of the main contributors of Reactive Streams. Other contributors include Red Hat, Oracle, Twitter and spray.io.

Goals The main goal of Reactive Streams is to govern the exchange of stream data across an asynchronous boundary – like passing elements on to another thread or thread-pool – while ensuring that the receiving side is not forced to buffer arbitrary amounts of data. In other words, back pressure is an integral part of this model in order to allow the queues which mediate between threads to be bounded. The intention of the specification is to allow the creation of many conforming implementations, which by virtue of abiding by the rules will be able to interoperate smoothly, preserving the mentioned benefits and characteristics across the whole processing graph of a stream application. A freely-available Technology Compatibility Kit was developed alongside the specification that allows implementors of the specification to verify if they covered all rules and requirements, including checks for potential race conditions. The scope of Reactive Streams is a minimal set of interfaces, methods and protocols that describe the necessary operations and entities to achieve the asynchronous streams of data with non-blocking back pressure. End-user DSLs or protocol binding APIs have purposefully been left out of the scope to encourage and enable different implementations that potentially use different programming languages to stay as true as possible to the idioms of their platform.

Inclusion in Java standard The specification developed with the intent of future inclusion in the official Java standard library, if proven successful and adopted by enough libraries and vendors. Reactive Streams were proposed to become part of Java 9 by Doug Lea, leader of JSR 166 as a new Flow class that would include the interfaces currently provided by Reactive Streams. After a successful 1.0 release of Reactive Streams and growing adoption, the proposal was accepted and Reactive Streams was included in JDK9 via the JEP-266.

Adoption On April 30, 2015 version 1.0.0 of Reactive Streams for the JVM was released, including Java API, a textual specification, a TCK and implementation examples. It comes with a multitude of compliant implementations verified by the TCK for 1.0.0, listed in alphabetical order:

Akka Streams MongoDB Ratpack Reactive Rabbit – driver for RabbitMQ/AMQP Spring and Pivotal Project Reactor Netflix RxJava Slick 3.0 Vert.x 3.0 Mutiny Helidon Other implementations include Cassandra, Elasticsearch, Apache Kafka, Parallel Universe Quasar, Play Framework, Armeria. Spring 5 is announced to be built upon Reactive Streams compatible Reactor Core. Amazon announced that its Amazon Web Services SDK would support Reactive Streams to provide streaming capabilities in its client libraries in version 2.0. Reactive Streams 1.0.1 is released on August 9, 2017, including various improvements in specification preciseness, TCK improvements and other clarifications. The specification as well as interfaces remained fully backwards compatible with the 1.0.0 version, however aimed to streamline the adoption for future implementors as well as align with some additional requirements set by the OpenJDK.

Ports and influences A direct port of the specification, interfaces and TCK was made available under the same working group for the .NET platform. When the Elixir language introduced its streaming API called GenStage, the authors extended a thanks "[to] akka-streams and reactive-streams projects which provided us guidance in implementing the demand-driven exchange between stages".

Citations

References Walls, Craig (October 2019). Spring in Action (Fifth ed.). Manning. p. 520. ISBN 9781617294945. This article incorporates text from www.reactive-streams.org, which is released under a CC0 1.0 Universal (CC0 1.0) Public Domain Dedication.

Worked examples

Example 1 — a first encounter with Reactive Streams

Start with the simplest possible case. Write down what Reactive Streams claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Reactive Streams before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Reactive Streams ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Reactive Streams

In research
Reactive Streams appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Reactive Streams in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Reactive Streams is common in secondary-school and first-year university syllabi. It links to neighbouring topics Java (software platform), Open standards, so understanding it makes those chapters shorter.
In everyday life
Look for Reactive Streams outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Reactive Streams in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Reactive Streams means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Reactive Streams out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Reactive Streams in simple terms?

Reactive Streams is an initiative to provide a standard for asynchronous stream processing with non-blocking back pressure. Origin Reactive Streams started as an initiative in late 2013 between engineers at Netflix, Pivotal and Lightbend.

Why does Reactive Streams matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Reactive Streams?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Reactive Streams.

Tags

  • Java (software platform)
  • Open standards

Keep exploring