map() method of Mono/Flux object in Project Reactor

Unlike the flatMap() method, the map() method of the Mono/Flux object in the Project Reactor will process the item being emitted, synchronously:

In the image above, green, yellow, and blue items emitted by Publisher will be processed by the map() method synchronously. The return result will be a Flux object with the items after being processed. You can add other tasks if you want.

My example is as follows:

In this example, I just do a simple operation that takes the length of the string plus 2. Then use the log() method to see what the values of the returned items are.

The result is as follows:

Add Comment