
Spring 5.0 Cookbook
By :

When it comes to propagating the result of an asynchronous service transaction, there are two popular APIs that are responsible for wrapping both the task and its result, namely Future<T>
and CallableFuture<T>
. These APIs can manage any asynchronous executions with or without a successful completion. This recipe will demonstrate the usage of these two containers and will also compare and contrast the two APIs.
Open ch08
again and add the following @Service
methods that return Future<T>
and CallableFuture<T>
task containers.
Another way of creating asynchronous services is using Future<T>
and CallableFuture<T>
as return values. Let us create these asynchronous APIs in our services by following these steps:
EmployeeServiceImpl
implementation class. Study the service methods readEmployees()
and readEmployee(id)
. The readEmployees()
passes the whole employee record retrieval...