Non-blocking queries in Spring Data for MongoDB?

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.Future
  • java.util.concurrent.CompletableFuture
  • org.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. , , - , . ;)

+5
2
So it not really non-blocking but just decoupling my thread using a thread pool which doesn't scale very well.

Non-Blocking/Asynchronous . Spring mongodb .

, , , Spring TaskExecutor SLA .

Spring data mongodb - , , / . , , API- Aync MongoDB.

+1

Source: https://habr.com/ru/post/1625915/


All Articles