Reactor

Reactor is a reactive framework from the Spring Pivotal team. It builds on top of Reactive Streams. As we will discuss later in this chapter, Spring Framework 5.0 uses the Reactor framework to enable reactive web features.

 

Dependencies for Reactor are shown as follows:

    <dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>
<dependency>
<groupId>io.projectreactor.addons</groupId>
<artifactId>reactor-test</artifactId>
<version>3.0.6.RELEASE</version>
</dependency>

Reactor adds in a couple of important things on top of the Subscriber, Consumer, and Subscriptions terminology introduced by Reactive Streams.

  • Flux: Flux represents a Reactive Stream that emits 0 to n element
  • Mono: Mono represents a Reactive Stream that emits either no elements or one element

In subsequent examples, we will create stub Mono and Flux objects, which would be pre-configured to emit elements at specific intervals. We will create Consumers (or Observers) to listen to these events and react to them.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset