官术网_书友最值得收藏!

Reactive Core and Streams

Java 8 introduced Reactive Core, which implements the Reactive programming model and is built on top of the Reactive Streams specification, a standard for building Reactive applications. As the lambda syntax gives more flexibility to go for the event-driven approach Java 8 provides the best way to support Reactive. Also, Java's lambda syntax gives us the ability to create and spawn up small and independent asynchronous tasks. One of the main goals of Reactive Streams is to address the problem of back pressure. We will talk more about back pressure in a later section of this chapter.

The main difference between Java 8 Streams and Reactive Streams is that Reactive is a push model, whereas Java 8 Streams focuses on pulling. In Reactive Streams, based on consumer needs and numbers, all events will be pushed to consumers.

Reactive programming model support is Spring 5's best feature since the last release. Also, with the support of the Akka and Play framework, Java 8 provides a better platform for Reactive applications.

Reactor is built on top of the Reactive Streams specification. Reactive Streams is a bundle of four Java interfaces:

  • Publisher
  • Subscriber
  • Subscription
  • Processor

Publisher will publish a stream of data items to the subscribers that registered with the Publisher. Using an executor, the Publisher publishes the items to the Subscriber. Also, Publisher makes sure that the Subscriber method invocations for each subscription are strictly ordered.

Subscriber consumes items only when requested. You can cancel the receiving process any time by using Subscription.

Subscription behaves as a message mediator between the Publisher and the Subscriber.

Processor represents a processing stage, which can include both Subscriber and a Publisher. Processor can initiate back pressure and cancel the subscription, as well.


Reactive Streams is a specification for asynchronous stream processing, which means all events can be produced and consumed asynchronously.
主站蜘蛛池模板: 吕梁市| 碌曲县| 紫云| 高密市| 团风县| 汪清县| 巍山| 翼城县| 曲沃县| 远安县| 依兰县| 昌宁县| 息烽县| 小金县| 容城县| 临清市| 河北区| 衡水市| 姜堰市| 肃宁县| 洪洞县| 沁水县| 石城县| 阜平县| 巴马| 克拉玛依市| 阳西县| 松原市| 从化市| 宝清县| 本溪市| 齐齐哈尔市| 桃园市| 灵武市| 庄浪县| 淅川县| 丰镇市| 屏东市| 镇坪县| 天津市| 临江市|