There is still a bottleneck in our application; when a user searches ten keywords, each search will be executed sequentially. We could easily improve the speed of our application by using different threads and launching all the searches at the same time.
To enable Spring's asynchronous capabilities, one must use the
@EnableAsync annotation. This will transparently execute any method annotated with
@Async using a
It is possible to customize the default executor used by implementing the
AsyncConfigurer interface. Let's create a new configuration class called
AsyncConfig in the
package masterSpringMvc.config; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; ...