June 2018
Intermediate to advanced
408 pages
11h 23m
English
When we want to execute a background activity task asynchronously and do not want to return anything from that task, we can use the CompletableFuture.runAsync() method. It takes a parameter as a Runnable object and returns the CompletableFuture<Void> type.
Let's try to use the runAsync() method by creating another controller method in our BankController class, with the following example:
@RequestMapping(value = "/synccust") @ResponseBody public CompletableFuture<String> syncCustomerDetails() { LOGGER.info("Entering in controller"); CompletableFuture<String> completableFuture = new CompletableFuture<>(); CompletableFuture.runAsync(new Runnable() { @Override public void run() { try { completableFuture.complete(syncService.syncCustomerAccount() ...Read now
Unlock full access