Sarvar Nishonboyev
Sarvar Nishonboyev

Reputation: 13090

Reactive API consumes external api

I'm building an API that consumes another external service's API and maps the response. Using WebClient to make an HTTP request. External API is not non-blocking.

I'm going to block fetchResult instead of returning Mono<ResultObject> as a response because I'm not sure if returning Mono response makes sense in case of external service is blocking.

So my question is If an external API is not non-blocking, does return a non-blocking response lose its meaning?

I hope my question is clear.

Upvotes: 0

Views: 504

Answers (1)

Jo&#227;o Dias
Jo&#227;o Dias

Reputation: 17460

It is irrelevant if the external API is blocking or non-blocking, HTTP protocol will be always in the middle. What you should definitely do is use Mono and Flux throughout your service. An important thing is that if you are using a database, it should also support the reactive stack so that you can take full advantage of using Spring Webflux.

Upvotes: 1

Related Questions