
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
What are the core interfaces of Reactive Streams in Java 9?
Java 9 has introduced Reactive Streams under java.util.concurrent.Flow package that supports an interoperable publish-subscribe framework. It processes an asynchronous stream of data across the asynchronous boundary (passing elements into another thread or thread-pool), and the receiving side is not forced to buffer arbitrary amounts of data, then buffer overflow can't occur.
Flow API contains four interrelated core interfaces: Publisher, Subscriber, Subscription, and Processor.
Syntax
@FunctionalInterface public static interface Publisher<T> { public void subscribe(Subscriber<? super T> subscriber) } public static interface Subscriber<T> { public void onSubscribe(Subscription subscription); public void onNext(T item); public void onError(Throwable throwable); public void onComplete(); } public static interface Subscription { public void request(long n); public void cancel(); } public static interface Processor<T, R> extends Subscriber<T>, Publisher<R> { }
These four interfaces: Flow.Publisher, Flow.Processor, Flow.Subscriber, and Flow. Subscription related to reactive stream specifications. The Publisher interface has subscribe() method, Subscription has cancel() and request() methods and Subscriber has onSubscribe(), onNext(), onError(), and onComplete() methods. The Processor interface implements all methods of Flow. Publisher and Flow.Subscriber interfaces.
- Related Articles
- How to implement reactive streams using Flow API in Java 9?
- What are the core library changes in Process API in Java 9?
- What are the SAM Interfaces in Java?
- Private Methods in Java 9 Interfaces
- What are nested interfaces in Java?
- What is the necessity of byte streams and character streams in Java?
- What are the in-built functional interfaces in Java?
- What is the purpose of interfaces in java?
- What is a Stream and what are the types of Streams and classes in Java?
- What are the methodologies of data streams clustering?
- What is the use of marker interfaces in Java?
- Streams in Java
- What are the advantages of Modules in Java 9?
- Why are interfaces introduced in Java?\n
- What are the data mining interfaces?
