June 2018
Intermediate to advanced
408 pages
11h 23m
English
In this mode, a method will be configured with a return type by wrapping the result with the Future type:
@Servicepublic class BankAsyncService { private static final Logger LOGGER = Logger.getLogger(BankAsyncService.class); @Async public Future<String> syncCustomerAccount() throws InterruptedException { LOGGER.info("Sync Account Processing Started - Thread id: " + Thread.currentThread().getId()); Thread.sleep(2000); String processInfo = String.format("Sync Account Processing Completed - Thread Name= %d, Thread Name= %s", Thread.currentThread().getId(), Thread.currentThread().getName()); LOGGER.info(processInfo); return new AsyncResult<String>(processInfo); }}
Spring also provides support for the AsyncResult ...
Read now
Unlock full access