Exploring the Reactor framework

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.

The dependencies for Reactor are 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 a couple of important things on top of the Subscriber, Consumer, and Subscriptions terminologies introduced by Reactive Streams:

  • Flux: Flux represents a Reactive stream that emits 0 to n elements.
  • 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 will 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