Spring WebFlux create pool of no-blocking threads

2019-05-26 14:52发布

问题:

I decided to rewrite my web app on Java(previously it was on Python). In my app I used no-blocking I/O, I had worker pool(Celery + Eventlet threads) where I pass tasks which consists of hundreds of API calls.

Now I'm using Spring WebFlux but I can't understand how I can create a workers pool to pass my tasks to that pool, and after get results and do some calculations.

(I know about possibility to create ThreadPoolTaskExecutor, but the threads are blocking threads)

回答1:

If you're using non-blocking APIs, you don't need to schedule tasks on specific threads - Reactor is doing that for you. With Spring WebFlux, the threads used for processing work are managed by Reactor or it is reusing the Netty threads.

Check out the Schedulers and threading parts of the reactor reference documentation.