com.github.imrafaelmerino.kafkacli.KafkaConsumers Maven / Gradle / Ivy
package com.github.imrafaelmerino.kafkacli;
import jio.ExceptionFun;
import jio.cli.ConsoleLogger;
import jio.cli.ConsolePrinter;
import jsonvalues.JsObj;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.common.errors.WakeupException;
import java.time.Duration;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.function.Function;
class KafkaConsumers implements
Function> {
private final Map> consumers;
private final ExecutorService service;
KafkaConsumers() {
consumers = new HashMap<>();
service = Executors.newCachedThreadPool();
Runtime.getRuntime()
.addShutdownHook(new Thread(() -> {
for (KafkaConsumer