I am trying to integrate Reactor 2x into an existing Spring 4 application to improve performance during the execution of a REST request, where resources can be selected independently, sorted by map, where we parallelize the task into several threads, and then combine them into a buffer.
So far, this sample works for us in the spring environment:
//Ordered resources to apply transformations. List<Map<String, Object>> result; result = Streams.from(resources) .flatMap(m -> Streams.just(m) .dispatchOn(Environment.cachedDispatcher()) .map(resourceToMapFunction::apply)) .buffer().next().await(5, TimeUnit.SECONDS);
In the example above, we apply the transformation using resourceToMapFunction , and then attach it using the buffer() method, create a Promise to wait for the result, and return result .
My first question is, is Reactor supposed to be used? I know that conversions apply correctly, but maybe I'm new to Reactor without using something correctly.
My second question is not a big problem, but is there anything in the Reactor project to return in the same order as the resources input? Since this is done in multiple threads, I am sure that there is no answer, and, as I said, this is less of my concern, but I wanted to ask anyway.
The last question, when I introduce this code into the Spring project, the conversion failed because the Bean dependencies for applying the subclass transformations are not included in the threads, is this what I can easily do using the Spring Reactor version? If so, is there a link or document that shows how to do this?
Thank you so much!
Jose louis
java spring multithreading reactor project-reactor
jbarrueta
source share