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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.