Reactive Streams spec in action

In general, as we might notice from the previous section, even though the interfaces from the Reactive Streams specification are straightforward, the overall concept is complex enough. Thus, we are going to learn the central idea and conceptual behaviors of those three interfaces in an everyday example.

Let's consider as an example a news subscription and how this may become smarter with new Reactive Streams interfaces. Consider the following code for creating a Publisher for a news service:

NewsServicePublisher newsService = new NewsServicePublisher();

Now let’s create a Subscriber and subscribe it to the NewsService:

NewsServiceSubscriber subscriber = new NewsServiceSubscriber(5);newsService.subscribe(subscriber); ...

Get Hands-On Reactive Programming in Spring 5 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.