How it works...

Building asynchronous services is recommended only for long transaction queues, voluminous transactions, and remote processing that experiences intermittent server communication. In the previous Spring versions, @Service methods that return Callable<T> are automatically considered non-blocking. It can be invoked by the anyRequest() handler - either synchronous or asynchronous - to execute its task. Another option is to use the method-level annotation @Async which can be applied to services that returns a value or void. Once DispatcherServlet encounters the @Async annotation, it tells TaskExecutor to allot a separate thread for its own asynchronous execution. Any controller or service that invokes the @Async method will not ...

Get Spring 5.0 Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.