Arc Reactor

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.

Reactive Streams

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:

  1. Using WebCient.create() or WebClient.builder() functions
  2. Autowiring the WebClient.Builder Bean which spring provides

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…

Aftab Shaikh

Application Developer @Thoughtworks

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store