import java.time.Duration;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.stream.Collectors;
{
private final String topic;
private final KafkaConsumer<String, String> consumer;
- private final ExecutorService executorService;
private final ObjectMapper mapper;
private final ConsumerUseCases productionUseCases, restoreUseCases;
// in the same thread, it would block the completion of the initialization.
// Hence, the app would not react to any signal (CTRL-C, for example) except
// a KILL until the restoring is finished.
- future = executorService.submit(() -> restore());
+ future = CompletableFuture.runAsync(() -> restore());
}
private void restore()
}
running = true;
- future = executorService.submit(this);
+ future = CompletableFuture.runAsync(this);
log.info("started");
return result;