10

I'm developing a reactive service and preparing to use the WebClient to exchange with HTTP APIs,but the service is not in a reactive web stack so how can I use it(WebClient) without depending on Webflux or is there any alternative reactive HTTP client? Thanks in advance.

Rui Chen
  • 109
  • 1
  • 3

1 Answers1

0

I am not sure if I get your question correct: You want to use an inherently reactive class without the reactive lib in which it is contained?

As you can see via the link you put in your question, the WebClient is part of spring-webflux and depends e.g. on reactor.core.publisher.Mono which resides in compile("io.projectreactor:reactor-core"). I can not imagine any scenario in which this WebClient would work or make any sense as you've asked "without depending on Webflux".

Other reactive HTTP clients are:

May be you could elaborate a little bit more on your needs, why you won't rely on WebFlux or why you want to use a reactive client in a non-reactive stack.

mle
  • 2,466
  • 1
  • 19
  • 25
  • 4
    You can use Spring Reactor in Spring MVC applications. You can return Mono and Flux from Spring MVC Controllers and they resolve asynchronously. See https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#webflux-programming-models and https://stackoverflow.com/a/51955755/855893 You might not have the full gains, but it is not that it makes not sense at all. – opncow Sep 07 '19 at 11:07
  • 8
    Because the Spring team has gone golden-hammer on reactive and refuses to support basic operations such as OAuth2 requests in RestTemplate. – chrylis -cautiouslyoptimistic- Aug 31 '21 at 03:09
  • 1
    @chrylis-cautiouslyoptimistic- they provide OAuth2 support for the both system webclient and resttemplate See https://docs.spring.io/spring-security/oauth/apidocs/org/springframework/security/oauth2/client/OAuth2RestTemplate.html – Quentin Oct 15 '22 at 15:30