Before we talk about what/why Reactor, let us first have a quick recap on Reactive Programming and Reactive Streams.
Reactive programming is a way of writing asynchronous, non-blocking code. It means that whenever there is a time consuming task like IO operation/api call the execution is switched to another active task and it comes back to the current task when the async processing has finished.
A simple way to think
Reactive: Reacts as soon as the data is available or the async execution is finished.
Dictionary says: A stream is a steady flow of something
In terms of computing, a…
Spring WebFlux provides the reactive WebClient to make asynchronous api calls. It is fully non-blocking. Things I like about WebClient is it integrates well with reactor api providing very readable code and it is configurable in every way, which we will see in a minute.
Let’s start with creating an instance of the WebClient. There are two ways to do so:
Once created, the WebClient is immutable which makes it thread safe. You can use webClient.mutate() to reconfigure it and get a new instance.
As we have created…
Application Developer @Thoughtworks