Can spring webclient be used with RESTful API which is not reactive based?

Viewed 1916

Is there any issues with using WebClient for fetching responses from multiple REST APIs which are not reactive based.

1 Answers

Yes, you definitely can, and in fact, the use of WebClient is encouraged by Spring officially. Also, the RestTemplate which is generally the preferred way of communication for REST-based services has already been deprecated.

Also, there are no issues when using WebClient in a non-reactive context

enter image description here

https://docs.spring.io/spring/docs/5.2.8.RELEASE/spring-framework-reference/web.html#webmvc-client

However, you'll explicitly have to call subscribe or block when using WebClient in a non-reactive context.

Related