Can I use a standalone WebClient without Webflux
Asked Answered
U

1

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.

Unstressed answered 30/3, 2019 at 13:51 Comment(0)
P
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.

Peddler answered 30/3, 2019 at 18:15 Comment(3)
You can use Spring Reactor in Spring MVC applications. You can return Mono and Flux from Spring MVC Controllers and they resolve asynchronously. See docs.spring.io/spring/docs/current/spring-framework-reference/… and https://mcmap.net/q/680148/-resttemplate-vs-webclient-benefits-in-servlet-based-web-mvc-app You might not have the full gains, but it is not that it makes not sense at all.Alfonsoalfonzo
Because the Spring team has gone golden-hammer on reactive and refuses to support basic operations such as OAuth2 requests in RestTemplate.Pallor
@chrylis-cautiouslyoptimistic- they provide OAuth2 support for the both system webclient and resttemplate See docs.spring.io/spring-security/oauth/apidocs/org/…Rebuff

© 2022 - 2024 — McMap. All rights reserved.