Асинхронная обработка данных в web-приложениях на Java |
Cообщение скрыто для удобства комментирования.
Прочитать сообщение
private final Queue<DeferredResult<String>> responseBodyQueue = new ConcurrentLinkedQueue<>();
@RequestMapping("/hellom")
@ResponseBody
public DeferredResult<String> hellom() throws InterruptedException, ExecutionException {
DeferredResult<String> deferredResult = new DeferredResult<>();
responseBodyQueue.add(deferredResult);
return deferredResult;
}
@Scheduled(fixedDelay = 2000) //TODO fixedDelay = для 1 потока
public void processQueues() throws InterruptedException, ExecutionException, Exception {
System.out.println("processQueues :" + responseBodyQueue.size());
for (DeferredResult<String> deferredResult : responseBodyQueue) {
lookupService.findPage(deferredResult);
responseBodyQueue.remove(deferredResult);
}
}
| Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |