Use it in reactive code; block() in a servlet app works but gives up the benefit and can deadlock on a small pool.
WebClient client = WebClient.create("https://api.example.com");
Mono<Order> mono = client.get()
.uri("/orders/{id}", 42)
.retrieve()
.bodyToMono(Order.class);
// Reactive: return the Mono
// Blocking (servlet stack): Order o = mono.block();
Nothing is sent until the Mono is subscribed to.
A forgotten .subscribe() or .block() means the request never happens at all.
Run this yourself in the Online Java Compiler, spin up a live REST API in the API Sandbox, or practise with Java interview questions.
Published 2026-08-11