Search code examples
springasynchronousspring-dataspring-data-restcompletable-future

How to make Spring Data REST endpoints asynchronous?


Does anyone know how to make Spring Data REST endpoints asynchronous?

I saw that we can add the annotation @Async with CompletableFuture<?> as returned object on the service methods. But doing this, makes the use of the interface RepositoryRestResource pointless as we need to implement both the service and controller layers manually...

Or am I missing something here?


Solution

  • Currently Spring Data REST supports blocking I/O only. See this Jira Issue of Spring Data REST support for Spring WebFlux.

    Spring MVC has an integration with Servlet 3.0 async request processing.

    Although Spring MVC has async support, for non-blocking I/O, Spring WebFlux is recommended, because Spring WebFlux is async by design. See Spring Web MVC Async Request Compared to WebFlux