Sitemap
Webencyclop

Webencyclop

Here to jot down notes for myself and help out others who are preparing too!

Reactive Stream API

2 min readOct 14, 2024

--

Reactive stream is a specification created by engineers from netflix, lightbend and vmware. It contains 4 interfaces

  • Reactive Streams is a specification that provides a standard for asynchronous stream processing with non-blocking back pressure.
  • It defines a set of interfaces and contracts that enable interoperability between different reactive libraries and components.
  • It defines a set of rules for asynchronous stream processing with non-blocking back pressure
  • The Reactive Streams API allows developers to build reactive applications and stream processing pipelines in a consistent and composable manner.
  • Reactive streams are introduced in java9

Reactive streams are immutable

  1. Publisher
  2. Subscriber
  3. Subscription
  4. Processor

Publisher

  • A Publisher is a provider of a potentially unbounded number of sequenced elements, publishing them according to the demand received from its Subscriber(s)
  • Publisher represents the datasource eg: database, remoteservers etc. which holds the data.
  • A Publisher can serve multiple Subscribers subscribed subscribe(Subscriber)

Get Webencyclop’s stories in your inbox

Join Medium for free to get updates from this writer.

public interface publisher<T>{
public void subscribe(Subscriber s);
}

subscribe

Subscriber

public interace subscriber<T>{
public void onSubscribe(Subscriber s);
public void onNext(T t);
public void onError(Throwable t);
public void onComplete();
}

Subscription

public interace Subscription<T>{
public void request(long n);
public void cancel();
}

Processor

processor extends Subscriber and publisher

public interface Processor<T, R> extends Subscriber<T>, Publisher<R>{
}

--

--

Webencyclop
Webencyclop