Reactive Programming with Reactor 3

Reactor
530.9K views

Open Source Your Knowledge, Become a Contributor

Technology knowledge has to be shared and made accessible for free. Join the movement.

Create Content

Merge

Merging sequences is the operation consisting of listening for values from several Publishers and emitting them in a single Flux.

On this first exercise we will begin by merging elements of two Flux as soon as they arrive. The caveat here is that values from flux1 arrive with a delay, so in the resulting Flux we start seeing values from flux2 first.

Simple Merge

But if we want to keep the order of sources, we can use the concat operator. Concat will wait for flux1 to complete before it can subscribe to flux2, ensuring that all the values from flux1 have been emitted, thus preserving an order corresponding to the source.

Keep the order

You can use concat with several Publisher. For example, you can get two Mono and turn them into a same-order Flux:

Create a flux from two mono
Open Source Your Knowledge: become a Contributor and help others learn. Create New Content