Why this matters
RestTemplateis deprecated — it blocks a thread for every outbound call and lacks a fluent API.RestClient(Boot 3.2+) is the modern blocking client: fluent, composable, and works with virtual threads.WebClientis the reactive non-blocking option; use it when the calling code is already on WebFlux or you need streaming responses.
RestClient (Boot 3.2+)
L1 · FresherFluent synchronous HTTP client replacing RestTemplate for blocking calls to payment APIs.
WebClient
L2 · IntermediateNon-blocking client for reactive stacks or when integrating with async pipelines.
@HttpExchange interfaces
L3 · AdvancedDeclarative clients similar to Feign — define interface methods mapped to remote REST operations.
Timeouts and retries
L4 · ExpertConfigure connect/read timeouts and Resilience4j retries — never use unbounded defaults in production.
Blocked virtual threads release their carrier — other virtual threads continue
Three HTTP clients at a glance
RestTemplate— synchronous, blocking, deprecated since Spring 6. Do not start new code with it.RestClient— synchronous, blocking, fluent builder API. Default choice for MVC apps on Boot 3.2+.WebClient— reactive, non-blocking, returnsMono/Flux. Pairs with WebFlux or fire-and-forget async.@HttpExchange— declarative interface backed byRestClientorWebClientviaHttpServiceProxyFactory.- Observation — all three integrate with Micrometer tracing when observation is enabled.
RestClient — the modern blocking client
// learn:fragment
@Configuration
public class HttpClientConfig {
@Bean
public RestClient inventoryRestClient(RestClient.Builder builder) {
return builder
.baseUrl("http://inventory-service:8081")
.defaultHeader("X-Service-Name", "bookstore-api")
.build();
}
}
The rest of this guide is part of Pro
Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.
Still to come · 2 sections
- WebClient — reactive outbound calls
- Declarative clients with @HttpExchange
Test yourself
Answer these before moving on — recall is what makes it stick.