Java Magazine, Jan/Feb 2018
ORACLE COM JAVAMAGAZINE JANUARY FEBRUARY 2018 28 reactive programming Forecast setTemperature collect Collectors toList Return a final completable future instance when all provided completable futures are completed return CompletableFuture allOf forecastList toArray new CompletableFuture forecastList size thenApply v forecastList stream map CompletionStage toCompletableFuture map CompletableFuture join collect Collectors toList Create an instance of ServiceResponse which contains the whole list of forecasts along with the processing time Create a completed future of it and combine to forecastCS in order to retrieve the forecasts and set into service response CompletableFuture completedFuture new ServiceResponse thenCombine forecastCS ServiceResponse forecasts whenCompleteAsync response throwable response setProcessingTime System currentTimeMillis startTime async resume response
You must have JavaScript enabled to view digital editions.