Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Code uses WebClient but blocks #79

Open
marschall opened this issue Sep 3, 2021 · 2 comments
Open

Code uses WebClient but blocks #79

marschall opened this issue Sep 3, 2021 · 2 comments

Comments

@marschall
Copy link

marschall commented Sep 3, 2021

The code uses the reactive WebClient but ends up calling #block() which, as the name suggests, blocks and therefore defeats the whole purpose of using WebClient in the first place. Examples:

The code should instead do one of the following:

  • Avoid calling #block() and instead call #subscribe()
  • Switch from the reactive WebClient to the blocking RestTemplate

Considering all the rest of the code is blocking (WebServiceTemplate, JpaRepository, …) WebClient seems like the better match.

@delixfe
Copy link
Contributor

delixfe commented Sep 6, 2021

@marschall Thanks for your feedback.

According to https://stackoverflow.com/questions/58513071/spring-mvc-to-spring-webflux-migration-block-vs-subscribe, using block seems to be the best way in our situation.

@marschall
Copy link
Author

The thread is explicit that going Mono / Flux and #subscribe is the way to go if you want to be reactive. #block is a good choice for cases when you want to migrate an existing servlet based application to reactive in a step by step fashion. If you decide to go down that route you still needs solutions for JPA and SOAP which to my knowledge have no reactive options.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants