microsoft/spring-data-cosmosdb

Reactive with Spring Data REST cosmos DB

tanayamitra05 opened this issue · 3 comments

Is there any significant time difference for fetching data by using Flux in reactive and normal List Collection in Java?

Depends on your use case, if fetching data using Flux is done in a completely asynchronous way, then that would be ideal and fastest.
Otherwise, if using blocking calls, its effectively same as using normal list collection in java.

I am fetching the data like:
Flux cmLogs = cmLogsRepository.findAll();
return cmLogs;

and the repository code:
public interface CMLogsRepository extends ReactiveCosmosRepository<CentralizedManagementEntity, String> {
Flux findAllById(String id);

But there is no such timing difference in this case.

@tanayamitra05 when you run reactive code like this :
Flux<T> cmLogs = cmLogsRepository.findAll(); it doesn't execute the find all operation at this point until you subscribe to it. So measuring timing at this point doesn't even makes sense.

Please read project reactor docs for more details on how to run reactive asynchronous code.
https://projectreactor.io/learn