Member-only story
Spring Boot Declarative Web Client | How to communicate with other API in reactive manner
In this article, I will show you how to employ a web client from Spring Boot 3.
Most projects I have been working on utilize Feign Declarative web clients, but Feign. But it seems like the Spring team decided to move to Spring Web Client, and they are not going to support Open Feign anymore since it required the rearchitecting of the project.
In this article, we will develop a client for Quote Garden.
What is Web Client ?
According to Spring Documentation:
Spring WebFlux includes a client to perform HTTP requests with.
WebClient
has a functional, fluent API based on Reactor, see Reactive Libraries, which enables declarative composition of asynchronous logic without the need to deal with threads or concurrency. It is fully non-blocking, it supports streaming, and relies on the same codecs that are also used to encode and decode request and response content on the server side.
Implementation
Let’s start with the definition of data transfer objects.
package io.vrnsky.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
public record Quote(
@JsonProperty("_id")
String id,
@JsonProperty("quoteText")
String qouteText,
@JsonProperty("quoteAuthor")
String quoteAuthor,
@JsonProperty("quoteGenre")…