I want to execute non-blocking database queries through Spring Data, accessing MongoDB using the Async MongoDB client API .
So far, I have only seen the opportunity to return
java.util.concurrent.Futurejava.util.concurrent.CompletableFutureorg.springframework.util.concurrent.ListenableFuture
and annotate the request method with @Asyncfor example
public interface UserRepo extends Repository <User, Long> {
@Async
ListenableFuture <User> findByName (String name);
}
but the documentation clearly states that the actual [...] query execution will occur in a task that has been submitted to a Spring TaskExecutor. So this is actually not non-blocking, but simply sharing my thread using a thread pool that does not scale very well.
So my question is:
How to execute queries in non-blocking mode using the NIO functions of the MongoDB Async driver?
, , - Spring Data API Mongo Async. , , - , . ;)