Conforme imagem, mesmo consumindo as menssagens o valor do LAG não está diminuindo, isto é normal?
Segue abaixo a classe de um dos consumers:
package br.com.rnsiquera.model;
import org.apache.kafka.clients.consumer.ConsumerConfig; 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.serialization.StringDeserializer;
import java.time.Duration; import java.util.Arrays; import java.util.Collections; import java.util.Properties;
public class LogServiceConsumer {
public static void main(String[] args) {
KafkaConsumer<String, String> consumer = new KafkaConsumer<>(properties());
consumer.subscribe(Arrays.asList("information", "products"));
while (true) {
ConsumerRecords<String, String> poll = consumer.poll(Duration.ofMillis(100));
if (!poll.isEmpty()) {
System.out.println("Encontrei message " + poll.count() + " registros!");
for (ConsumerRecord<String, String> p : poll) {
System.out.println("Processing Log service consumer");
System.out.println(p.key());
System.out.println(p.value());
System.out.println(p.partition());
System.out.println(p.offset());
}
} else System.out.println("No Messages!!!");
}
}
private static Properties properties() {
Properties properties = new Properties();
properties.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");
properties.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
properties.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
properties.put(ConsumerConfig.GROUP_ID_CONFIG, LogServiceConsumer.class.getSimpleName());
properties.put(ConsumerConfig.CLIENT_ID_CONFIG, "01");
properties.put(ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG, 1);
return properties;
}
}