Recently I asked question Spring WebFlux create pool of no-blocking threads
I got the answer, read link provided, but still don't understand the right way of doing such stuff.
I use Spring WebFlux (WebClient) to write my REST service. For each incoming request I make several hundred requests to another REST service, so to make them as fast as possible I want to use no-blocking threads.
Let I got request from client and I have to make 600 API calls:
List<String> urls = Arrays.asList("www.example-rest.com/url1", "www.example-rest.com/url2", ..., "www.example-rest.com/url600");
- I want to make them in parallel way and using no-blocking threads (like eventlet in Python)
- I want to create separate shared worker pool with such threads in order not to make one for each incoming request.
Here is the documentation about schedulers http://projectreactor.io/docs/core/release/reference/#schedulers
I found there information about elastic thread pool:
An elastic thread pool (Schedulers.elastic()). It creates new worker pools as needed, and reuse idle ones. This is a good choice for I/O blocking work for instance. Schedulers.elastic() is a handy way to give a blocking process its own thread, so that it does not tie up other resources.
But I can't create new worker pool for each request, and thread inside that pool still works in blocking way.
If anybody did similar task with Spring WebClient please provide an example, explain what is the right way.